comparison blast_unmatched.py @ 2:dfcdac284538 draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/blast_unmatched commit 830e10a94c2afc178f4078609842cd93808df1b4
author artbio
date Thu, 05 Oct 2017 05:11:01 -0400
parents 50c1fa95a076
children fffdb903f2d1
comparison
equal deleted inserted replaced
1:50c1fa95a076 2:dfcdac284538
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 import optparse 3 import optparse
4 4 import re
5 5
6 def parse_options(): 6 def parse_options():
7 """ 7 """
8 Parse the options guiven to the script 8 Parse the options guiven to the script
9 """ 9 """
34 """ 34 """
35 Compares matched queries to query fasta file and print unmatched to ouput 35 Compares matched queries to query fasta file and print unmatched to ouput
36 """ 36 """
37 output_file_handle = open(output_file, 'w') 37 output_file_handle = open(output_file, 'w')
38 unmatched = False 38 unmatched = False
39 end = re.compile(".+\W$")
39 with open(fasta_file, 'r') as infile: 40 with open(fasta_file, 'r') as infile:
40 for line in infile: 41 for line in infile:
41 if line.startswith('>'): 42 if line.startswith('>'):
42 subline = line[1:100].rstrip() #qid are 100chars long in blast 43 subline = line[1:].rstrip() #qid are 100chars long in blast
44 while end.match(subline) != None:
45 subline = subline[:-1]
43 if subline not in matched: 46 if subline not in matched:
44 output_file_handle.write(line) 47 output_file_handle.write(line)
45 unmatched = True 48 unmatched = True
46 else: 49 else:
47 unmatched = False 50 unmatched = False