Mercurial > repos > cpt > cpt_search_file
annotate searchFile.py @ 1:6e3a843b6304 draft
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
| author | cpt | 
|---|---|
| date | Mon, 05 Jun 2023 02:53:18 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
1
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
1 ##### User input File(s), that are BLAST XML, gff3, and/or Genbank and then searched for containing user designated terms | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
2 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
3 import argparse | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
4 import explodeJSON as ej | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
5 import gffutils # THIS IS REQUIREMENT | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
6 from Bio.Blast import NCBIXML | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
7 from Bio import SeqIO | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
8 import re | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
9 import os | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
10 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
11 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
12 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
13 ####### TERM FUNCTIONS | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
14 def dbaseTerms(terms, galaxy=True): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
15 """Index into dictionary object and retrieve all desired terms""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
16 db_path = os.path.join(SCRIPT_DIR, "data/lysis-family-v1.0.3.json") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
17 db = ej.explodeJSON(db_path) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
18 db = db.readJSON() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
19 dbase_terms = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
20 if terms: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
21 for term in terms: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
22 index_list = term.split(",") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
23 for t in index_list: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
24 if t != "None": | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
25 dbase_terms.extend(db[t]) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
26 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
27 dbase_terms = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
28 return dbase_terms | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
29 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
30 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
31 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
32 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
33 def userTerms(file, text): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
34 """Select terms input by user""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
35 user_terms = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
36 if file: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
37 terms = open(file.name).read().splitlines() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
38 user_terms.extend(terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
39 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
40 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
41 if text: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
42 if re.search(("__cn__"), str(text[0])): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
43 # s = text[0].split("__cn__") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
44 # print(s) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
45 # print(text[0]) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
46 s = text[0] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
47 # print(type(s)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
48 split = s.split("__cn__") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
49 # print(split) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
50 user_terms.extend(split) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
51 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
52 user_terms.extend(text) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
53 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
54 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
55 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
56 return user_terms | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
57 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
58 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
59 def glueTerms(dbase_terms, user_terms): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
60 """glue dbaseTerms and userTerms together for eventual query item""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
61 glued = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
62 if dbase_terms: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
63 glued.extend(dbase_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
64 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
65 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
66 if user_terms: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
67 glued.extend(user_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
68 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
69 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
70 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
71 return glued | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
72 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
73 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
74 ####### FILE FUNCTIONS | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
75 def glueFiles(gff, gbk, fa, blast): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
76 """glue files into one list...I think this is a decent way to go about this...#CHECK LATER#...""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
77 files = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
78 gffs = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
79 gbks = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
80 blasts = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
81 if gff: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
82 for gff_file in gff: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
83 gffs.extend(gff_file) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
84 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
85 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
86 if gbk: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
87 for gbk_file in gbk: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
88 gbks.extend(gbk_file) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
89 # print(gbks) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
90 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
91 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
92 fas = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
93 if fa: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
94 for fa_file in fa: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
95 fas.extend(fa_file) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
96 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
97 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
98 if blast: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
99 for blast_file in blast: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
100 blasts.extend(blast_file) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
101 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
102 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
103 files = [gffs, gbks, fas, blasts] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
104 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
105 return files | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
106 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
107 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
108 ######## PARSE FILE FUNCTIONS | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
109 def readGFF3(files, search_list): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
110 "Searches through gff3 file(s) and appends" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
111 if files: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
112 for idx, file in enumerate(files): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
113 if idx == 0: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
114 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
115 db = gffutils.create_db( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
116 file.name, dbfn="file.db", force=True, keep_order=False | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
117 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
118 db = gffutils.FeatureDB("file.db") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
119 features = db.all_features() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
120 gff3_matches = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
121 for feature in features: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
122 gff3_matches.extend( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
123 searchInput(str(feature), search_list=search_list) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
124 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
125 gff3_matches = list( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
126 set(gff3_matches) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
127 ) # make sure we don't fluff the list | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
128 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
129 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
130 db = gffutils.create_db( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
131 file.name, dbfn=str(idx) + "_file.db", force=True, keep_order=False | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
132 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
133 db = gffutils.FeatureDB(str(idx) + "_file.db") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
134 features = db.all_features() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
135 for feature in features: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
136 gff3_matches.extend( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
137 searchInput(str(feature), search_list=search_list) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
138 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
139 gff3_matches = list( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
140 set(gff3_matches) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
141 ) # make sure we don't fluff the list | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
142 gff3_matches.sort() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
143 return gff3_matches | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
144 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
145 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
146 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
147 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
148 def readGBK(files, search_list): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
149 if files: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
150 for idx, file in enumerate(files): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
151 if idx == 0: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
152 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
153 record = SeqIO.read(file.name, "genbank") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
154 gbk_matches = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
155 for feature in record.features: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
156 try: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
157 if ( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
158 searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
159 str(feature.qualifiers["product"]), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
160 search_list=search_list, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
161 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
162 or searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
163 str(feature.qualifiers["note"]), search_list=search_list | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
164 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
165 or searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
166 str(feature.qualifiers["dbxref"]), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
167 search_list=search_list, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
168 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
169 ): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
170 gbk_matches.extend([str(feature)]) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
171 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
172 continue | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
173 except KeyError: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
174 continue | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
175 gbk_matches = list(set(gbk_matches)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
176 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
177 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
178 record = SeqIO.read(file.name, "genbank") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
179 for feature in record.features: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
180 try: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
181 if ( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
182 searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
183 str(feature.qualifiers["product"]), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
184 search_list=search_list, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
185 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
186 or searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
187 str(feature.qualifiers["note"]), search_list=search_list | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
188 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
189 or searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
190 str(feature.qualifiers["dbxref"]), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
191 search_list=search_list, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
192 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
193 ): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
194 gbk_matches.extend([str(feature)]) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
195 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
196 continue | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
197 except KeyError: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
198 continue | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
199 gbk_matches = list(set(gbk_matches)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
200 gbk_matches.sort() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
201 return gbk_matches | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
202 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
203 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
204 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
205 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
206 def readFASTA(files, search_list): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
207 if files: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
208 for idx, file in enumerate(files): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
209 if idx == 0: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
210 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
211 record = SeqIO.parse(file.name, "fasta") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
212 fa_matches = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
213 for feature in record: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
214 fa_matches.extend( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
215 searchInput(feature.description, search_list=search_list) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
216 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
217 fa_matches = list(set(fa_matches)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
218 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
219 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
220 record = SeqIO.parse(file.name, "fasta") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
221 for feature in record: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
222 fa_matches.extend( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
223 searchInput(feature.description, search_list=search_list) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
224 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
225 fa_matches = list(set(fa_matches)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
226 fa_matches.sort() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
227 return fa_matches | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
228 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
229 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
230 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
231 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
232 def readBLAST(files, search_list): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
233 if files: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
234 for idx, file in enumerate(files): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
235 if idx == 0: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
236 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
237 blast_records = NCBIXML.parse(open(file.name)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
238 blast_matches = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
239 for blast_record in blast_records: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
240 for desc in blast_record.descriptions: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
241 pretty = prettifyXML(str(desc)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
242 for each_ret in pretty: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
243 blast_matches.extend( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
244 searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
245 each_ret, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
246 search_list=search_list, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
247 blast=True, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
248 q_id=blast_record.query, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
249 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
250 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
251 blast_matches = list(set(blast_matches)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
252 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
253 print("Parsing - " + file.name) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
254 blast_records = NCBIXML.parse(open(file.name)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
255 for blast_record in blast_records: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
256 for desc in blast_record.descriptions: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
257 pretty = prettifyXML(str(desc)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
258 blast_matches.extend( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
259 searchInput( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
260 each_ret, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
261 search_list=search_list, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
262 blast=True, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
263 q_id=blast_record.query, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
264 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
265 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
266 blast_matches = list(set(blast_matches)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
267 blast_matches.sort() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
268 return blast_matches | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
269 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
270 pass | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
271 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
272 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
273 ######## SEARCH FILE FUNCTIONS | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
274 def searchInput(input, search_list, blast=False, q_id=None): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
275 """Takes an input search string, and returns uniques of passing""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
276 output = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
277 for search_term in search_list: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
278 if blast: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
279 if re.search(re.escape(search_term), input): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
280 add_query = ( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
281 "QueryID: " | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
282 + str(q_id) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
283 + "\nSearchQuery: " | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
284 + search_term | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
285 + "\nMatch: " | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
286 + input | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
287 + "\n" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
288 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
289 output.extend([add_query]) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
290 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
291 continue | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
292 # print(search_term) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
293 # st = r"\b"+search_term+r"\b" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
294 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
295 if re.search(re.escape(search_term), input): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
296 # print(search_term+" -> was found") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
297 output.extend([input]) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
298 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
299 continue | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
300 return list(set(output)) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
301 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
302 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
303 ######## prettify-XML function | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
304 def prettifyXML(input): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
305 """prettifies a string input from a BLAST-xml""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
306 s = input | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
307 split = s.split(">") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
308 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
309 return split | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
310 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
311 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
312 ########## Output File Writer | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
313 def writeResults(gffs, gbks, fas, blasts, outName="termHits.txt"): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
314 """Takes an input list for each parameter, and writes each result to the output file""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
315 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
316 with open(outName.name, "w+") as out_file: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
317 if gffs: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
318 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
319 out_file.writelines( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
320 "\n==================== GFF3 Term Hits ====================\n\n" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
321 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
322 for gff_hits in gffs: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
323 out_file.writelines(gff_hits + "\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
324 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
325 gffs = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
326 if gbks: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
327 out_file.writelines( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
328 "\n==================== GBK Term Hits ====================\n\n" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
329 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
330 for gbk_hits in gbks: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
331 out_file.writelines(gbk_hits + "\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
332 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
333 gbks = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
334 if fas: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
335 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
336 out_file.writelines( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
337 "\n==================== FASTA Term Hits ====================\n\n" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
338 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
339 for fa_hits in fas: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
340 out_file.writelines(fa_hits + "\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
341 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
342 fas = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
343 if blasts: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
344 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
345 out_file.writelines( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
346 "\n==================== BLAST Term Hits ====================\n\n" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
347 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
348 for blast_hits in blasts: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
349 out_file.writelines(blast_hits + "\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
350 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
351 blasts = [] | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
352 if len(gffs) or len(gbks) or len(fas) or len(blasts): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
353 print("Terms Found") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
354 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
355 out_file.writelines("No query matches, try again with new terms!") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
356 print("No query matches, try again with new terms!") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
357 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
358 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
359 def write_gff3(gffs, outName="proxHits.gff3"): | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
360 """writes output to gff3 file for prox2lysis pipeline""" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
361 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
362 with open(outName.name, "w+") as out_file: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
363 out_file.writelines("##gff-version 3\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
364 if gffs: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
365 for gff_hits in gffs: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
366 out_file.writelines(gff_hits + "\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
367 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
368 # raise Exception("No terms were found from query set") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
369 out_file.writelines("##No terms were found from query set\n") | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
370 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
371 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
372 if __name__ == "__main__": | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
373 print(os.getcwd()) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
374 parser = argparse.ArgumentParser( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
375 description="Uses a selection of terms to query an input file for matching cases" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
376 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
377 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
378 "--dbaseTerms", nargs="*", help="dbase terms to search" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
379 ) # will be a select option, based on KEY within the JSON dbase | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
380 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
381 "--custom_txt", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
382 nargs="*", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
383 help="custom user input terms, if using Galaxy, terms will be __cn__ sep, otherwise by space", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
384 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
385 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
386 "--custom_file", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
387 type=argparse.FileType("r"), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
388 help="custom new line separated search term file", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
389 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
390 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
391 "--gff3_files", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
392 type=argparse.FileType("r"), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
393 nargs="*", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
394 action="append", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
395 help="GFF3 File(s), if multiple files, use another flag", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
396 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
397 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
398 "--gbk_files", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
399 type=argparse.FileType("r"), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
400 nargs="*", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
401 action="append", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
402 help="GBK File(s), if multiple files, use another flag", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
403 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
404 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
405 "--fa_files", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
406 type=argparse.FileType("r"), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
407 nargs="*", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
408 action="append", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
409 help="FASTA File(s), if multiple files, use another flag", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
410 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
411 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
412 "--blast_files", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
413 type=argparse.FileType("r"), | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
414 nargs="*", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
415 action="append", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
416 help="BLAST.xml File(s), if multiple files, use another flag", | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
417 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
418 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
419 "--output", type=argparse.FileType("w+"), default="termHits.txt" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
420 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
421 parser.add_argument( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
422 "--prox", action="store_true", help="Use when running the prox2lysis pipeline" | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
423 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
424 args = parser.parse_args() | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
425 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
426 ############ STEP I | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
427 ##### Determine user's terms to query | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
428 dbase_terms = dbaseTerms(terms=args.dbaseTerms, galaxy=True) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
429 user_terms = userTerms(file=args.custom_file, text=args.custom_txt) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
430 glued_terms = glueTerms(dbase_terms=dbase_terms, user_terms=user_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
431 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
432 ############ STEP II | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
433 ##### Create list with matches | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
434 files = glueFiles( | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
435 gff=args.gff3_files, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
436 gbk=args.gbk_files, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
437 fa=args.fa_files, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
438 blast=args.blast_files, | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
439 ) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
440 gffs = readGFF3(files=files[0], search_list=glued_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
441 gbks = readGBK(files=files[1], search_list=glued_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
442 fas = readFASTA(files=files[2], search_list=glued_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
443 blasts = readBLAST(files=files[3], search_list=glued_terms) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
444 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
445 ############ STEP III | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
446 ##### Output results to a text file or gff3 | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
447 if args.prox: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
448 write_gff3(gffs, outName=args.output) | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
449 else: | 
| 
 
6e3a843b6304
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
 
cpt 
parents:  
diff
changeset
 | 
450 writeResults(gffs, gbks, fas, blasts, outName=args.output) | 
