comparison blastxml_to_gapped_gff3.py @ 17:4c201a3d4755 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit a37bfdfc108501b11c7b2aa15efb1bd16f0c4b66
author fubar
date Sun, 28 Jan 2024 06:48:52 +0000
parents d78175596286
children b1260bca5fdc
comparison
equal deleted inserted replaced
16:1fe91657bfd6 17:4c201a3d4755
30 "BLASTP": "protein_match", 30 "BLASTP": "protein_match",
31 }.get(record.application, "match") 31 }.get(record.application, "match")
32 32
33 recid = record.query 33 recid = record.query
34 if " " in recid: 34 if " " in recid:
35 recid = recid[0: recid.index(" ")] 35 recid = recid[0 : recid.index(" ")]
36 36
37 rec = SeqRecord(Seq("ACTG"), id=recid) 37 rec = SeqRecord(Seq("ACTG"), id=recid)
38 for idx_hit, hit in enumerate(record.alignments): 38 for idx_hit, hit in enumerate(record.alignments):
39 for idx_hsp, hsp in enumerate(hit.hsps): 39 for idx_hsp, hsp in enumerate(hit.hsps):
40 qualifiers = { 40 qualifiers = {
70 "sbjct_end", 70 "sbjct_end",
71 ): 71 ):
72 qualifiers["blast_" + prop] = getattr(hsp, prop, None) 72 qualifiers["blast_" + prop] = getattr(hsp, prop, None)
73 73
74 desc = hit.title.split(" >")[0] 74 desc = hit.title.split(" >")[0]
75 qualifiers["description"] = desc[desc.index(" "):] 75 qualifiers["description"] = desc[desc.index(" ") :]
76 76
77 # This required a fair bit of sketching out/match to figure out 77 # This required a fair bit of sketching out/match to figure out
78 # the first time. 78 # the first time.
79 # 79 #
80 # the match_start location must account for queries and 80 # the match_start location must account for queries and
159 prev = 0 159 prev = 0
160 fq = "" 160 fq = ""
161 fm = "" 161 fm = ""
162 fs = "" 162 fs = ""
163 for position in re.finditer("-", query): 163 for position in re.finditer("-", query):
164 fq += query[prev: position.start()] 164 fq += query[prev : position.start()]
165 fm += match[prev: position.start()] 165 fm += match[prev : position.start()]
166 fs += subject[prev: position.start()] 166 fs += subject[prev : position.start()]
167 prev = position.start() + 1 167 prev = position.start() + 1
168 fq += query[prev:] 168 fq += query[prev:]
169 fm += match[prev:] 169 fm += match[prev:]
170 fs += subject[prev:] 170 fs += subject[prev:]
171 171
288 "--trim", 288 "--trim",
289 action="store_true", 289 action="store_true",
290 help="Trim blast hits to be only as long as the parent feature", 290 help="Trim blast hits to be only as long as the parent feature",
291 ) 291 )
292 parser.add_argument( 292 parser.add_argument(
293 "--trim_end", action="store_true", help="Cut blast results off at end of gene" 293 "--trim_end",
294 action="store_true",
295 help="Cut blast results off at end of gene",
294 ) 296 )
295 parser.add_argument("--include_seq", action="store_true", help="Include sequence") 297 parser.add_argument("--include_seq", action="store_true", help="Include sequence")
296 args = parser.parse_args() 298 args = parser.parse_args()
297 299
298 for rec in blastxml2gff3(**vars(args)): 300 for rec in blastxml2gff3(**vars(args)):