-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58ff77b
commit 0584337
Showing
5 changed files
with
75 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Mon Oct 10 10:22:56 2016 | ||
@author: philipp | ||
""" | ||
# Library sanity check | ||
# ======================================================================= | ||
# Imports | ||
import yaml | ||
import sys | ||
import os | ||
import pandas | ||
|
||
def LibrarySanityCheck(): | ||
# ------------------------------------------------ | ||
# Get parameters | ||
# ------------------------------------------------ | ||
configFile = open('configuration.yaml','r') | ||
config = yaml.load(configFile) | ||
configFile.close() | ||
LibDir = config['LibDir'] | ||
LibFilename = config['LibFilename'] | ||
LibFormat = LibFilename[-3:] | ||
if LibFormat == 'tsv': | ||
libsep = '\t' | ||
elif LibFormat == 'csv': | ||
libsep = ',' | ||
|
||
# ---------------------------------- | ||
# Read library | ||
# ---------------------------------- | ||
os.chdir(LibDir) | ||
LibCols = ['gene','ID','seq'] | ||
LibFile = pandas.read_table(LibFilename, sep = libsep, skiprows = 1, names = LibCols) | ||
GeneNames = list(LibFile['gene']) | ||
ID = list(LibFile['ID']) | ||
seq = list(LibFile['seq']) | ||
|
||
# ---------------------------------- | ||
# Replace non-printable characters (...these cause problems in PlotCount.py) | ||
# ---------------------------------- | ||
GeneNames0 = [] | ||
for gene in GeneNames: | ||
gene = gene.replace('|','_') | ||
gene = gene.replace('(','_') | ||
gene = gene.replace(')','_') | ||
gene = gene.replace(';','_') | ||
gene = gene.replace('"','') | ||
gene = gene.replace('/','_') | ||
gene = gene.replace('\\','_') | ||
GeneNames0.append(gene) | ||
if GeneNames != GeneNames0: | ||
LibFile0 = pandas.DataFrame(data = {'gene': [gene for gene in GeneNames0], | ||
'ID': [id for id in ID], | ||
'seq': [s for s in seq]}, | ||
columns = ['gene','ID','seq']) | ||
LibFile0.to_csv(LibFilename, sep = libsep, index = False) | ||
print("WARNING: Found non-printable characters in library file. Replaced by '_' ") | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
LibrarySanityCheck() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters