Mercurial > repos > iuc > blastxml_to_gapped_gff3
annotate blastxml_to_gapped_gff3.py @ 0:bd47051afe98 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
author | iuc |
---|---|
date | Tue, 20 Dec 2016 09:21:11 -0500 |
parents | |
children | 877cd0833221 |
rev | line source |
---|---|
0
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
1 #!/usr/bin/perl |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
2 import argparse |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
3 import copy |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
4 import logging |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
5 import re |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
6 import sys |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
7 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
8 from BCBio import GFF |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
9 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
10 logging.basicConfig(level=logging.INFO) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
11 log = logging.getLogger(name='blastxml2gff3') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
12 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
13 __author__ = "Eric Rasche" |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
14 __version__ = "0.4.0" |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
15 __maintainer__ = "Eric Rasche" |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
16 __email__ = "esr@tamu.edu" |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
17 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
18 __doc__ = """ |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
19 BlastXML files, when transformed to GFF3, do not normally show gaps in the |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
20 blast hits. This tool aims to fill that "gap". |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
21 """ |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
22 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
23 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
24 def blastxml2gff3(blastxml, min_gap=3, trim=False, trim_end=False): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
25 from Bio.Blast import NCBIXML |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
26 from Bio.Seq import Seq |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
27 from Bio.SeqRecord import SeqRecord |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
28 from Bio.SeqFeature import SeqFeature, FeatureLocation |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
29 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
30 blast_records = NCBIXML.parse(blastxml) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
31 records = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
32 for record in blast_records: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
33 # http://www.sequenceontology.org/browser/release_2.4/term/SO:0000343 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
34 match_type = { # Currently we can only handle BLASTN, BLASTP |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
35 'BLASTN': 'nucleotide_match', |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
36 'BLASTP': 'protein_match', |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
37 }.get(record.application, 'match') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
38 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
39 rec = SeqRecord(Seq("ACTG"), id=record.query) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
40 for hit in record.alignments: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
41 for hsp in hit.hsps: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
42 qualifiers = { |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
43 "source": "blast", |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
44 "score": hsp.expect, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
45 "accession": hit.accession, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
46 "hit_id": hit.hit_id, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
47 "length": hit.length, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
48 "hit_titles": hit.title.split(' >') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
49 } |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
50 desc = hit.title.split(' >')[0] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
51 qualifiers['description'] = desc[desc.index(' '):] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
52 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
53 # This required a fair bit of sketching out/match to figure out |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
54 # the first time. |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
55 # |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
56 # the match_start location must account for queries and |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
57 # subjecst that start at locations other than 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
58 parent_match_start = hsp.query_start - hsp.sbjct_start |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
59 # The end is the start + hit.length because the match itself |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
60 # may be longer than the parent feature, so we use the supplied |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
61 # subject/hit length to calculate the real ending of the target |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
62 # protein. |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
63 parent_match_end = hsp.query_start + hit.length + hsp.query.count('-') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
64 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
65 # However, if the user requests that we trim the feature, then |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
66 # we need to cut the ``match`` start to 0 to match the parent feature. |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
67 # We'll also need to cut the end to match the query's end. It (maybe) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
68 # should be the feature end? But we don't have access to that data, so |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
69 # We settle for this. |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
70 if trim: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
71 if parent_match_start < 1: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
72 parent_match_start = 0 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
73 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
74 if trim or trim_end: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
75 if parent_match_end > hsp.query_end: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
76 parent_match_end = hsp.query_end + 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
77 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
78 # The ``match`` feature will hold one or more ``match_part``s |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
79 top_feature = SeqFeature( |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
80 FeatureLocation(parent_match_start, parent_match_end), |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
81 type=match_type, strand=0, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
82 qualifiers=qualifiers |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
83 ) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
84 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
85 # Unlike the parent feature, ``match_part``s have sources. |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
86 part_qualifiers = { |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
87 "source": "blast", |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
88 } |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
89 top_feature.sub_features = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
90 for start, end, cigar in generate_parts(hsp.query, hsp.match, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
91 hsp.sbjct, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
92 ignore_under=min_gap): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
93 part_qualifiers['Gap'] = cigar |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
94 part_qualifiers['ID'] = hit.hit_id |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
95 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
96 if trim: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
97 # If trimming, then we start relative to the |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
98 # match's start |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
99 match_part_start = parent_match_start + start |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
100 else: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
101 # Otherwise, we have to account for the subject start's location |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
102 match_part_start = parent_match_start + hsp.sbjct_start + start - 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
103 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
104 # We used to use hsp.align_length here, but that includes |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
105 # gaps in the parent sequence |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
106 # |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
107 # Furthermore align_length will give calculation errors in weird places |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
108 # So we just use (end-start) for simplicity |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
109 match_part_end = match_part_start + (end - start) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
110 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
111 top_feature.sub_features.append( |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
112 SeqFeature( |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
113 FeatureLocation(match_part_start, match_part_end), |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
114 type="match_part", strand=0, |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
115 qualifiers=copy.deepcopy(part_qualifiers)) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
116 ) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
117 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
118 rec.features.append(top_feature) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
119 rec.annotations = {} |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
120 records.append(rec) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
121 return records |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
122 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
123 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
124 def __remove_query_gaps(query, match, subject): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
125 """remove positions in all three based on gaps in query |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
126 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
127 In order to simplify math and calculations...we remove all of the gaps |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
128 based on gap locations in the query sequence:: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
129 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
130 Q:ACTG-ACTGACTG |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
131 S:ACTGAAC---CTG |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
132 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
133 will become:: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
134 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
135 Q:ACTGACTGACTG |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
136 S:ACTGAC---CTG |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
137 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
138 which greatly simplifies the process of identifying the correct location |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
139 for a match_part |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
140 """ |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
141 prev = 0 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
142 fq = '' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
143 fm = '' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
144 fs = '' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
145 for position in re.finditer('-', query): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
146 fq += query[prev:position.start()] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
147 fm += match[prev:position.start()] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
148 fs += subject[prev:position.start()] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
149 prev = position.start() + 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
150 fq += query[prev:] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
151 fm += match[prev:] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
152 fs += subject[prev:] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
153 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
154 return (fq, fm, fs) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
155 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
156 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
157 def generate_parts(query, match, subject, ignore_under=3): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
158 region_q = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
159 region_m = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
160 region_s = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
161 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
162 (query, match, subject) = __remove_query_gaps(query, match, subject) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
163 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
164 region_start = -1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
165 region_end = -1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
166 mismatch_count = 0 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
167 for i, (q, m, s) in enumerate(zip(query, match, subject)): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
168 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
169 # If we have a match |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
170 if m != ' ' or m == '+': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
171 if region_start == -1: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
172 region_start = i |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
173 # It's a new region, we need to reset or it's pre-seeded with |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
174 # spaces |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
175 region_q = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
176 region_m = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
177 region_s = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
178 region_end = i |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
179 mismatch_count = 0 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
180 else: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
181 mismatch_count += 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
182 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
183 region_q.append(q) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
184 region_m.append(m) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
185 region_s.append(s) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
186 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
187 if mismatch_count >= ignore_under and region_start != -1 and region_end != -1: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
188 region_q = region_q[0:-ignore_under] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
189 region_m = region_m[0:-ignore_under] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
190 region_s = region_s[0:-ignore_under] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
191 yield region_start, region_end + 1, \ |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
192 cigar_from_string(region_q, region_m, region_s, strict_m=True) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
193 region_q = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
194 region_m = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
195 region_s = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
196 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
197 region_start = -1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
198 region_end = -1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
199 mismatch_count = 0 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
200 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
201 yield region_start, region_end + 1, \ |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
202 cigar_from_string(region_q, region_m, region_s, strict_m=True) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
203 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
204 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
205 def _qms_to_matches(query, match, subject, strict_m=True): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
206 matchline = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
207 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
208 for (q, m, s) in zip(query, match, subject): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
209 ret = '' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
210 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
211 if m != ' ' or m == '+': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
212 ret = '=' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
213 elif m == ' ': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
214 if q == '-': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
215 ret = 'D' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
216 elif s == '-': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
217 ret = 'I' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
218 else: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
219 ret = 'X' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
220 else: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
221 log.warn("Bad data: \n\t%s\n\t%s\n\t%s\n" % (query, match, subject)) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
222 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
223 if strict_m: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
224 if ret == '=' or ret == 'X': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
225 ret = 'M' |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
226 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
227 matchline.append(ret) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
228 return matchline |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
229 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
230 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
231 def _matchline_to_cigar(matchline): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
232 cigar_line = [] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
233 last_char = matchline[0] |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
234 count = 0 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
235 for char in matchline: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
236 if char == last_char: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
237 count += 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
238 else: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
239 cigar_line.append("%s%s" % (last_char, count)) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
240 count = 1 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
241 last_char = char |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
242 cigar_line.append("%s%s" % (last_char, count)) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
243 return ' '.join(cigar_line) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
244 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
245 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
246 def cigar_from_string(query, match, subject, strict_m=True): |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
247 matchline = _qms_to_matches(query, match, subject, strict_m=strict_m) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
248 if len(matchline) > 0: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
249 return _matchline_to_cigar(matchline) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
250 else: |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
251 return "" |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
252 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
253 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
254 if __name__ == '__main__': |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
255 parser = argparse.ArgumentParser(description='Convert Blast XML to gapped GFF3', epilog='') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
256 parser.add_argument('blastxml', type=open, help='Blast XML Output') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
257 parser.add_argument('--min_gap', type=int, help='Maximum gap size before generating a new match_part', default=3) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
258 parser.add_argument('--trim', action='store_true', help='Trim blast hits to be only as long as the parent feature') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
259 parser.add_argument('--trim_end', action='store_true', help='Cut blast results off at end of gene') |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
260 args = parser.parse_args() |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
261 |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
262 result = blastxml2gff3(**vars(args)) |
bd47051afe98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/blastxml_to_gapped_gff3 commit 8f38145c94ecb1e23c3ff6f0243213dc49d2287e
iuc
parents:
diff
changeset
|
263 GFF.write(result, sys.stdout) |