Enable fasta_to_len conversion to use only first word in title; this is standards compliant and used by default for automatic conversion.

This commit is contained in:
Jeremy Goecks
2012-03-08 11:09:14 -05:00
parent 6ff2de32dc
commit 047c1bff2f
2 changed files with 8 additions and 4 deletions
@@ -9,7 +9,7 @@ import sys, os
assert sys.version_info[:2] >= ( 2, 4 )
def compute_fasta_length( fasta_file, out_file, keep_first_char ):
def compute_fasta_length( fasta_file, out_file, keep_first_char, keep_first_word=False ):
infile = fasta_file
out = open( out_file, 'w')
@@ -32,6 +32,8 @@ def compute_fasta_length( fasta_file, out_file, keep_first_char ):
continue
if line[0] == '>':
if first_entry == False:
if keep_first_word:
fasta_title = fasta_title.split()[0]
out.write( "%s\t%d\n" % ( fasta_title[ 1:keep_first_char ], seq_len ) )
else:
first_entry = False
@@ -41,8 +43,10 @@ def compute_fasta_length( fasta_file, out_file, keep_first_char ):
seq_len += len(line)
# last fasta-entry
if keep_first_word:
fasta_title = fasta_title.split()[0]
out.write( "%s\t%d\n" % ( fasta_title[ 1:keep_first_char ], seq_len ) )
out.close()
if __name__ == "__main__" :
compute_fasta_length( sys.argv[1], sys.argv[2], sys.argv[3] )
if __name__ == "__main__" :
compute_fasta_length( sys.argv[1], sys.argv[2], sys.argv[3], True )
+1 -1
View File
@@ -6,4 +6,4 @@ Uses fasta_to_len converter code.
import sys
from galaxy.datatypes.converters.fasta_to_len import compute_fasta_length
compute_fasta_length( sys.argv[1], sys.argv[2], sys.argv[3])
compute_fasta_length( sys.argv[1], sys.argv[2], sys.argv[3], False )