annotate mature_mir_gff_translation.py @ 8:3f62272192f9 draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 0eaefbad21786cabed6791a6d06e9a0de8af10b0
author artbio
date Mon, 23 Apr 2018 13:21:16 -0400
parents 9ea96a02c416
children 2a08a6eb471c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
1 import argparse
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
2 from datetime import datetime
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
3
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
4
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
5 def Parser():
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
6 the_parser = argparse.ArgumentParser()
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
7 the_parser.add_argument(
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
8 '--input', action="store", type=str, help="input miRBase GFF3 file")
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
9 the_parser.add_argument(
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
10 '--output', action="store", type=str,
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
11 help="output GFF3 file with converted mature mir coordinates")
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
12 args = the_parser.parse_args()
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
13 return args
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
14
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
15
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
16 def get_gff_header(gff_input_file):
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
17 string_list = []
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
18 for line in open(gff_input_file, "r"):
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
19 if line[0] == '#':
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
20 string_list.append(line)
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
21 string_list.append('# generated by mature_mir_gff_translation.py %s\n#\n' %
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
22 str(datetime.now()))
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
23 return ''.join(string_list)
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
24
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
25
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
26 def load_gff_in_dict(gff_input_file):
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
27 '''
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
28 Reads the gff3 file and return a dictionary of dictionaries
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
29 with keys equal to standard gff3 fields (9)
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
30 Note that the key of the primary dictionary is the ID
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
31 '''
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
32 gff_dict = {}
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
33 for line in open(gff_input_file, "r"):
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
34 if line[0] == "#":
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
35 continue
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
36 gff_fields = line[:-1].split("\t")
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
37 ID = gff_fields[8].split("ID=")[1].split(";")[0]
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
38 gff_dict[ID] = {}
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
39 gff_dict[ID]["seqid"] = gff_fields[0]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
40 gff_dict[ID]["source"] = gff_fields[1]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
41 gff_dict[ID]["type"] = gff_fields[2]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
42 gff_dict[ID]["start"] = gff_fields[3]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
43 gff_dict[ID]["end"] = gff_fields[4]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
44 gff_dict[ID]["score"] = gff_fields[5]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
45 gff_dict[ID]["strand"] = gff_fields[6]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
46 gff_dict[ID]["phase"] = gff_fields[7]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
47 gff_dict[ID]["attributes"] = gff_fields[8]
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
48 if "erives_from" in gff_dict[ID]["attributes"]:
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
49 parent_primary_transcript = gff_dict[ID]["attributes"].split(
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
50 "erives_from=")[1]
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
51 parent_primary_transcript = gff_dict[parent_primary_transcript][
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
52 "attributes"].split("Name=")[1]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
53 gff_dict[ID]["attributes"] = "%s;Parent_mir_Name=%s" % (
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
54 gff_dict[ID]["attributes"], parent_primary_transcript)
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
55 return gff_dict
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
56
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
57
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
58 def genome_to_mir_gff(gff_dict, output, header):
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
59 '''
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
60 Converts seqid field from chromosome to item Name
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
61 Then converts coordinates relative to "miRNA_primary_transcript"
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
62 Note that GFF files are 1-based coordinates
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
63 '''
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
64 for key in gff_dict:
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
65 name = gff_dict[key]["attributes"].split("Name=")[1].split(";")[0]
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
66 gff_dict[key]["seqid"] = name
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
67 if "erives_from=" in gff_dict[key]["attributes"]:
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
68 parent_ID = gff_dict[key]["attributes"].split(
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
69 "erives_from=")[1].split(";")[0]
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
70 gff_dict[key]["start"] = str(int(gff_dict[key]["start"])-int(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
71 gff_dict[parent_ID]["start"])+1)
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
72 gff_dict[key]["end"] = str(int(gff_dict[key]["end"])-int(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
73 gff_dict[parent_ID]["start"])+1)
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
74 hairpins = {}
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
75 matures = {}
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
76 # treats miRNA_primary_transcript coordinates
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
77 # in a second loop to avoid errors in conversion
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
78 for key in gff_dict:
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
79 if gff_dict[key]["type"] == "miRNA_primary_transcript":
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
80 gff_dict[key]["end"] = str(int(gff_dict[key]["end"])-int(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
81 gff_dict[key]["start"]) + 1)
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
82 gff_dict[key]["start"] = '1'
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
83 # now, do a dict[ID]=Name but only for miRNA_primary_transcript
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
84 hairpins[key] = gff_dict[key]["attributes"].split(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
85 "Name=")[1].split(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
86 ";")[0]
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
87 else:
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
88 matures[key] = gff_dict[key]["attributes"].split(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
89 "Name=")[1].split(
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
90 ";")[0]
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
91 with open(output, "w") as output:
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
92 output.write(header)
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
93 for ID in sorted(hairpins, key=hairpins.get):
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
94 output.write("\t".join([gff_dict[ID]["seqid"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
95 gff_dict[ID]["source"], gff_dict[ID]["type"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
96 gff_dict[ID]["start"], gff_dict[ID]["end"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
97 gff_dict[ID]["score"], gff_dict[ID]["strand"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
98 gff_dict[ID]["phase"], gff_dict[ID]["attributes"]]))
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
99 output.write("\n")
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
100 for id in sorted(matures, key=matures.get, reverse=True):
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
101 if ID in gff_dict[id]["attributes"]:
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
102 output.write("\t".join([gff_dict[id]["seqid"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
103 gff_dict[id]["source"], gff_dict[id]["type"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
104 gff_dict[id]["start"], gff_dict[id]["end"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
105 gff_dict[id]["score"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
106 gff_dict[id]["strand"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
107 gff_dict[id]["phase"],
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
108 gff_dict[id]["attributes"]]))
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
109 output.write("\n")
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
110
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
111
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
112 def main(infile, outfile):
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
113 gff_dict = load_gff_in_dict(infile)
5
9ea96a02c416 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 04980585c257ab5f8eb5d10de007316c47c5d1ce
artbio
parents: 3
diff changeset
114 genome_to_mir_gff(gff_dict, outfile, get_gff_header(infile))
0
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
115
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
116
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
117 if __name__ == "__main__":
da29af78a960 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff changeset
118 args = Parser()
3
6b8adacd4750 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit fa65a844f9041a83767f5305ab360abfdf68f59f
artbio
parents: 0
diff changeset
119 main(args.input, args.output)