mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
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:
@@ -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 )
|
||||
@@ -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 )
|
||||
Reference in New Issue
Block a user