diff trams.py @ 7:8de0ffc2166f draft default tip

Uploaded
author rreumerman
date Mon, 10 Jun 2013 09:40:54 -0400
parents bd5692103d5b
children
line wrap: on
line diff
--- 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;