Mercurial > repos > artbio > mircounts
annotate mature_mir_gff_translation.py @ 4:b7ac138bb781 draft default tip
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
author | artbio |
---|---|
date | Sun, 09 May 2021 17:06:45 +0000 |
parents | ee99c6374a3b |
children |
rev | line source |
---|---|
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
1 import argparse |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
2 from datetime import datetime |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
3 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
4 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
5 def Parser(): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
6 the_parser = argparse.ArgumentParser() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
7 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
8 '--gff_path', action="store", type=str, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
9 help="path to miRBase GFF3 file") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
10 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
11 '--output', action="store", type=str, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
12 help="output GFF3 file with converted mature mir coordinates") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
13 args = the_parser.parse_args() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
14 return args |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
15 |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
16 |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
17 def convert_and_print_gff(gff_input_file, output): |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
18 |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
19 def get_gff_header(gff_input_file): |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
20 string_list = [] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
21 for line in open(gff_input_file, "r"): |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
22 if line[0] == '#': |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
23 string_list.append(line) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
24 string_list.append('# generated by mature_mir_gff_translation.py \ |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
25 %s\n#\n' % str(datetime.now())) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
26 return ''.join(string_list) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
27 |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
28 gff_dict = {} |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
29 # see https://github.com/ARTbio/tools-artbio/issues/246 |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
30 # currently fixed by perl pretreatment or the gff3 file |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
31 for line in open(gff_input_file, "r"): |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
32 if line[0] == "#": |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
33 continue |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
34 gff_fields = line[:-1].split("\t") |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
35 ID = gff_fields[8].split("ID=")[1].split(";")[0] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
36 if gff_fields[2] == "miRNA_primary_transcript": |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
37 gff_dict[ID] = {} |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
38 gff_dict[ID]["premir_name"] = gff_fields[8].split( |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
39 "Name=")[1].split(";")[0] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
40 gff_dict[ID]["primary"] = line[:-1] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
41 gff_dict[ID]["miRNAs"] = [] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
42 elif gff_fields[2] == "miRNA": |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
43 if "_" in ID: |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
44 continue |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
45 parent_ID = gff_fields[8].split("erives_from=")[1] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
46 gff_dict[parent_ID]["miRNAs"].append(line[:-1]) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
47 # Now reorganise features and recalculate coordinates of premirs and mirs |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
48 gff_list = [] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
49 for ID in sorted(gff_dict, key=lambda x: (gff_dict[x]['premir_name'])): |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
50 # delete premir and their mir with ID containing "_" |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
51 if "_" in ID: |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
52 del gff_dict[ID] |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
53 else: |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
54 primary_fields = gff_dict[ID]["primary"].split('\t') |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
55 seqid = primary_fields[8].split("Name=")[1].split(";")[0] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
56 source = primary_fields[1] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
57 type = primary_fields[2] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
58 start = primary_fields[3] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
59 newstart = "1" |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
60 end = primary_fields[4] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
61 newend = str(int(end)-int(start)+1) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
62 score = primary_fields[5] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
63 strand = primary_fields[6] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
64 phase = primary_fields[7] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
65 attributes = primary_fields[8] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
66 gff_list.append('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s' % (seqid, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
67 source, type, newstart, newend, score, strand, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
68 phase, attributes)) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
69 # ensure their is only 2 child miRNAs at best |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
70 if len(gff_dict[ID]["miRNAs"]) > 2: |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
71 gff_dict[ID]["miRNAs"] = gff_dict[ID]["miRNAs"][:2] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
72 # sort child miRNAs 5p first 3p second, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
73 # if there are two miR mature at least ! |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
74 if len(gff_dict[ID]["miRNAs"]) > 1 and \ |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
75 gff_dict[ID]["miRNAs"][0].find('5p') == -1: |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
76 gff_dict[ID]["miRNAs"] = gff_dict[ID]["miRNAs"][::-1] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
77 for mir in gff_dict[ID]["miRNAs"]: |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
78 mir_fields = mir.split('\t') |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
79 mir_seqid = mir_fields[8].split("Name=")[1].split(";")[0] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
80 mir_source = mir_fields[1] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
81 mir_type = mir_fields[2] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
82 mir_start = mir_fields[3] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
83 mir_end = mir_fields[4] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
84 new_mir_start = str(int(mir_start)-int(start)+1) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
85 new_mir_end = str(int(mir_end)-int(start)+1) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
86 mir_score = mir_fields[5] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
87 mir_strand = mir_fields[6] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
88 mir_phase = mir_fields[7] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
89 mir_attributes = mir_fields[8] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
90 mir_sfx = ";Parent_mir_Name=%s" % gff_dict[ID]["premir_name"] |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
91 gff_list.append( |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
92 '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s%s' % ( |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
93 mir_seqid, mir_source, mir_type, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
94 new_mir_start, new_mir_end, mir_score, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
95 mir_strand, mir_phase, mir_attributes, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
96 mir_sfx)) |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
97 with open(output, "w") as output: |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
98 output.write('%s' % get_gff_header(gff_input_file)) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
99 output.write('\n'.join(gff_list)) |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
100 output.write('\n') |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
101 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
102 |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
103 def main(gff_path, outfile): |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
104 convert_and_print_gff(gff_path, outfile) |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
105 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
106 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
107 if __name__ == "__main__": |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
108 args = Parser() |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
109 main(args.gff_path, args.output) |