comparison blastxmlToGff3.py @ 31:d8049deb0c97 draft

planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
author yating-l
date Fri, 17 Mar 2017 12:28:32 -0400
parents e4f3f2ed4fa5
children 15b4a74722d1
comparison
equal deleted inserted replaced
30:daf6a1122200 31:d8049deb0c97
5 from collections import OrderedDict 5 from collections import OrderedDict
6 import utils 6 import utils
7 7
8 8
9 def align2cigar(hsp_query, hsp_reference): 9 def align2cigar(hsp_query, hsp_reference):
10 ''' 10 """
11 Build CIGAR representation from an hsp_query 11 Build CIGAR representation from an hsp_query
12 input: 12 input:
13 hsp_query 13 hsp_query
14 hsp_sbjct 14 hsp_sbjct
15 output: 15 output:
16 CIGAR string 16 CIGAR string
17 ''' 17 """
18 query = hsp_query 18 query = hsp_query
19 ref = hsp_reference 19 ref = hsp_reference
20 # preType, curType: 20 # preType, curType:
21 # 'M' represents match, 21 # 'M' represents match,
22 # 'I' represents insert a gap into the reference sequence, 22 # 'I' represents insert a gap into the reference sequence,
96 target_len *= 3 96 target_len *= 3
97 target_end = target_start + target_len -1 97 target_end = target_start + target_len -1
98 attribute['ID'] = field['seqid'] + '_' + str(field['start']) + '_' + str(field['end']) + '_' + query_name + '_' + str(target_start) + '_' + str(target_end) 98 attribute['ID'] = field['seqid'] + '_' + str(field['start']) + '_' + str(field['end']) + '_' + query_name + '_' + str(target_start) + '_' + str(target_end)
99 attribute['Target'] = query_name + " " + str(target_start) + " " + str(target_end) 99 attribute['Target'] = query_name + " " + str(target_start) + " " + str(target_end)
100 attribute['Gap'] = align2cigar(query, ref) 100 attribute['Gap'] = align2cigar(query, ref)
101 #store the query sequence in the file in order to display alignment with BlastAlignment plugin
102 attribute['query'] = hsp.query
101 # show reading frame attribute only if the frame is not (0, 0) 103 # show reading frame attribute only if the frame is not (0, 0)
102 if hsp.frame[0] != 0 or hsp.frame[1] != 0: 104 if hsp.frame[0] != 0 or hsp.frame[1] != 0:
103 attribute['reading_frame'] = str(hsp.frame[0]) + ", " + str(hsp.frame[1]) 105 attribute['reading_frame'] = str(hsp.frame[0]) + ", " + str(hsp.frame[1])
104 utils.write_features(field, attribute, gff3) 106 utils.write_features(field, attribute, gff3)
105 107