changeset 7:8de0ffc2166f draft default tip

Uploaded
author rreumerman
date Mon, 10 Jun 2013 09:40:54 -0400
parents e711f63e99ff
children
files tablemerger.py tablemerger.xml trams.py
diffstat 2 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/tablemerger.py	Fri Apr 05 05:06:42 2013 -0400
+++ b/tablemerger.py	Mon Jun 10 09:40:54 2013 -0400
@@ -16,11 +16,14 @@
         continue
 
 # Fetch headers and print them to output file;
-headers = [header.readline()[:-1].split('\t')[2:] for header in files]
-columns = [len(strains) for strains in headers]
-for strain in [a for b in headers for a in b]:
-    output.write('\t'+strain)
-    output.flush()
+headers = [File.readline()[:-1].split('\t')[1:] for File in files]
+columns = [len(strains[1:]) for strains in headers]
+output.write('\t'.join(['Position']+[headers[0][0]]+[a for b in headers for a in b[1:]]))
+##headers = [header.readline()[:-1].split('\t')[2:] for header in files]
+##columns = [len(strains) for strains in headers]
+##for strain in [a for b in headers for a in b]:
+##    output.write('\t'+strain)
+##    output.flush()
 
 file_active = [True]*len(files)
 snps = [row.readline()[:-1].split('\t') for row in files]
--- a/trams.py	Fri Apr 05 05:06:42 2013 -0400
+++ b/trams.py	Mon Jun 10 09:40:54 2013 -0400
@@ -4,8 +4,8 @@
  | Tool for Rapid Annotation of Microbial SNPs (TRAMS): a simple    |
  | program for rapid annotation of genomic variation in prokaryotes |
  |                                                                  |
- | Developed by: Richard A. Reumerman, Paul R. Herron,              |
- | Paul A. Hoskisson and Vartul Sangal                              |
+ | Developed by: Richard A. Reumerman, Nick P. Tucker, Paul R.      |
+ | Herron, Paul A. Hoskisson and Vartul Sangal                      |
  +------------------------------------------------------------------+\n'''
 #################
 
@@ -195,7 +195,8 @@
                 codon[i][j+2] = ['MNP',strain[1],'','']
                 straininfo[j]['mnps'] += 1
                 new_codons[j] = new_codon_calc(new_codons[j],strain[1],pos_in_cod)
-            elif strain[0] == 'Allele missing': codon[i][j+2] = strain
+            elif strain[0] == 'Missing allele':
+                codon[i][j+2] = strain
             else: codon[i][j+2] = ['']*4
 
     for line in codon[1:-1]:
@@ -289,6 +290,7 @@
 props = {}# Properties of a feature;
 prev_snp = ''# Position of previous SNP;
 to_write = []# Information of current SNP;
+allowed_chars = ['g','a','t','c','','-']
 compl_bases = {'a':'t','t':'a','g':'c','c':'g'}
 firstsnp = True# First snp of region, or of codon in cases of 3 positions in codon mutated;
 prev_start=j=k=0
@@ -329,11 +331,11 @@
         snp_entry[-1] = snp_entry[-1].rstrip()# Remove newline character at end of line;
 
 	# Prevent crash upon encounter nonstandard base character;
-	if snp_entry[1] not in ['a','g','c','t']:# Ref base
+	if snp_entry[1].lower() not in allowed_chars:# Ref base
 	    i += 1
 	    continue
 	for m,base in enumerate(snp_entry[2:],2):
-	    if base.lower() not in ['a','g','c','t']:
+	    if base.lower() not in allowed_chars:
 		snp_entry[m] = ''
 	# Crash prevented
 
@@ -409,11 +411,11 @@
 
             snp = snp.lower()
             if snp == '':# Empty cell;
-                to_write.append(['','','',''])
+                to_write.append(['']*4)
                 continue
 
             if snp == '-': # Feature not present in this strain;
-                to_write.append(['Allele missing','','',''])
+                to_write.append(['Missing allele','','',''])
                 continue
 
             if snp_feat == -1:# Intergenic;