Mercurial > repos > artbio > mircounts
annotate mature_mir_gff_translation.py @ 1:cadc0f2c6b29 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit b403f95dd2e57e51932fa275bdaed5312ffc1ff1
author | artbio |
---|---|
date | Tue, 25 Jul 2017 09:40:25 -0400 |
parents | da29af78a960 |
children | 6b8adacd4750 |
rev | line source |
---|---|
0
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
1 #!/usr/bin/env python |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
2 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
3 import sys |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
4 import argparse |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
5 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
6 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
7 def Parser(): |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
8 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
|
9 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
|
10 '--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
|
11 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
|
12 '--output', action="store", type=str, help="output GFF3 file with converted mature mir coordinates") |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
13 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
|
14 return args |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
15 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
16 GFF3_header= '''##gff-version 3 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
17 ##generated by mature_mir_gff_translation.py |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
18 # |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
19 # Chromosomal coordinates of microRNAs ** relative to the hairpin precursors ** |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
20 # microRNAs: miRBase current_version |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
21 # genome-build-id: check http://mirbase.org/ |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
22 # |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
23 # Hairpin precursor sequences have type "miRNA_primary_transcript". |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
24 # Note, these sequences do not represent the full primary transcript, |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
25 # rather a predicted stem-loop portion that includes the precursor |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
26 # miRNA. Mature sequences have type "miRNA". |
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 ''' |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
29 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
30 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
|
31 ''' |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 ''' |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
36 gff_dict = {} |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
37 for line in open(gff_input_file, "r"): |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
38 if line[0]=="#": |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
39 continue |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
40 gff_fields=line[:-1].split("\t") |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
41 ID=gff_fields[8].split("ID=")[1].split(";")[0] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
42 gff_dict[ID] = {} |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
43 gff_dict[ID]["seqid"]=gff_fields[0] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
44 gff_dict[ID]["source"]=gff_fields[1] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
45 gff_dict[ID]["type"]=gff_fields[2] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
46 gff_dict[ID]["start"]=gff_fields[3] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
47 gff_dict[ID]["end"]=gff_fields[4] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
48 gff_dict[ID]["score"]=gff_fields[5] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
49 gff_dict[ID]["strand"]=gff_fields[6] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
50 gff_dict[ID]["phase"]=gff_fields[7] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
51 gff_dict[ID]["attributes"]=gff_fields[8] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
52 if "Derives_from" in gff_dict[ID]["attributes"]: |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
53 parent_primary_transcript=gff_dict[ID]["attributes"].split("Derives_from=")[1] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
54 parent_primary_transcript=gff_dict[parent_primary_transcript]["attributes"].split("Name=")[1] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
55 gff_dict[ID]["attributes"]="%s;Parent_mir_Name=%s" % (gff_dict[ID]["attributes"], parent_primary_transcript) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
56 return gff_dict |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
57 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
58 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
59 def genome_to_mir_gff(gff_dict, output): |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
60 ''' |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 ''' |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
65 for key in gff_dict: |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
66 name=gff_dict[key]["attributes"].split("Name=")[1].split(";")[0] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
67 gff_dict[key]["seqid"]=name |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
68 if "Derives_from=" in gff_dict[key]["attributes"]: |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
69 parent_ID=gff_dict[key]["attributes"].split("Derives_from=")[1].split(";")[0] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
70 gff_dict[key]["start"]=str(int(gff_dict[key]["start"]) - int(gff_dict[parent_ID]["start"]) + 1) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
71 gff_dict[key]["end"]=str(int(gff_dict[key]["end"]) - int(gff_dict[parent_ID]["start"]) + 1) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
72 hairpins={} |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
73 matures={} |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
74 for key in gff_dict: ## treats miRNA_primary_transcript coordinates in a second loop to avoid errors in conversion |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
75 if gff_dict[key]["type"]=="miRNA_primary_transcript": |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
76 gff_dict[key]["end"]=str(int(gff_dict[key]["end"]) - int(gff_dict[key]["start"]) + 1) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
77 gff_dict[key]["start"]="1" |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
78 # now, do a dict[ID]=Name but only for miRNA_primary_transcript |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
79 hairpins[key]=gff_dict[key]["attributes"].split("Name=")[1].split(";")[0] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
80 else: |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
81 matures[key]=gff_dict[key]["attributes"].split("Name=")[1].split(";")[0] |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
82 with open(output, "w") as output: |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
83 output.write(GFF3_header) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
84 for ID in sorted(hairpins, key=hairpins.get): |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
85 output.write("\t".join([gff_dict[ID]["seqid"], gff_dict[ID]["source"], |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
86 gff_dict[ID]["type"], gff_dict[ID]["start"], gff_dict[ID]["end"], |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
87 gff_dict[ID]["score"], gff_dict[ID]["strand"], gff_dict[ID]["phase"], |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
88 gff_dict[ID]["attributes"]])) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
89 output.write("\n") |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
90 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
|
91 if ID in gff_dict[id]["attributes"]: |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
92 output.write("\t".join([gff_dict[id]["seqid"], gff_dict[id]["source"], |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
93 gff_dict[id]["type"], gff_dict[id]["start"], gff_dict[id]["end"], |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
94 gff_dict[id]["score"], gff_dict[id]["strand"], |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
95 gff_dict[id]["phase"], gff_dict[id]["attributes"]])) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
96 output.write("\n") |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
97 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
98 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
99 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
|
100 gff_dict = load_gff_in_dict(infile) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
101 genome_to_mir_gff(gff_dict, outfile) |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
102 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
103 |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
104 if __name__ == "__main__": |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
105 args = Parser() |
da29af78a960
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
106 main(args.input, args.output) |