Commits

Anonymous committed 91a4379

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

  • Participants
  • Parent commits 5ffd9f8

Comments (0)

Files changed (2)

File lib/galaxy/datatypes/converters/fasta_to_len.py

 
 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')
             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
             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 )

File tools/fasta_tools/fasta_compute_length.py

 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 )