annotate AnnotateRNAz.py @ 0:5d006d19f70a draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
author bgruening
date Wed, 30 Jan 2019 04:12:32 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
1 # AnnotateRnaz.py ---
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
2 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
3 # Filename: AnnotateRnaz.py
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
4 # Description:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
5 # Author: Joerg Fallmann
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
6 # Maintainer:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
7 # Created: Sat Jan 26 12:45:25 2019 (+0100)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
8 # Version:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
9 # Package-Requires: ()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
10 # Last-Updated: Tue Jan 29 13:52:57 2019 (+0100)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
11 # By: Joerg Fallmann
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
12 # Update #: 188
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
13 # URL:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
14 # Doc URL:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
15 # Keywords:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
16 # Compatibility:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
17 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
18 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
19
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
20 # Commentary:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
21 # This script is a replacement for rnazAnnotate.pl
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
22 # rnazAnnotate can not handle the output from version 2 adequatly
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
23 # This script uses the bedtools API to fast intersect an annotation Bed
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
24 # with output from RNAz
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
25
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
26 # Change Log:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
27 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
28 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
29 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
30 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
31 # This program is free software: you can redistribute it and/or modify
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
32 # it under the terms of the GNU General Public License as published by
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
33 # the Free Software Foundation, either version 3 of the License, or (at
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
34 # your option) any later version.
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
35 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
36 # This program is distributed in the hope that it will be useful, but
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
37 # WITHOUT ANY WARRANTY; without even the implied warranty of
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
38 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
39 # General Public License for more details.
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
40 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
41 # You should have received a copy of the GNU General Public License
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
42 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
43 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
44 #
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
45
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
46 # Code:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
47
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
48 #!/usr/bin/env python3
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
49
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
50 import sys
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
51 import glob
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
52 import argparse
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
53 from io import StringIO
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
54 import gzip
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
55 import traceback as tb
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
56 import pybedtools
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
57 import re
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
58 import tempfile
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
59
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
60 def parseargs():
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
61 parser = argparse.ArgumentParser(description='Intersect RNAz output with Annotation from BED')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
62 parser.add_argument("-b", "--bed", type=str, help='Annotation BED file')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
63 parser.add_argument("-i", "--input", type=str, help='RNAz output')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
64 parser.add_argument("-o", "--bedout", type=str, help='Annotation BED output')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
65 parser.add_argument("-r", "--rnazout", type=str, help='Annotation rnaz output')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
66 return parser.parse_args()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
67
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
68 def annotate(bed, input, bedout, rnazout):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
69 try:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
70
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
71 pybedtools.set_tempdir('.') # Make sure we do not write somewhere we are not supposed to
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
72 anno = pybedtools.BedTool(bed)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
73 rnaz=readrnaz(input)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
74 tmpbed = pybedtools.BedTool(rnaztobed(rnaz), from_string=True)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
75
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
76 intersection = tmpbed.intersect(anno,wa=True,wb=True,s=True) # intersect strand specific, keep all info on a and b files
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
77
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
78 bedtornaz(intersection, rnaz, bedout, rnazout)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
79
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
80 return 1
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
81
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
82 except Exception as err:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
83 exc_type, exc_value, exc_tb = sys.exc_info()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
84 tbe = tb.TracebackException(
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
85 exc_type, exc_value, exc_tb,
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
86 )
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
87 print(''.join(tbe.format()),file=sys.stderr)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
88
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
89 def readin(file):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
90 try:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
91 if '.gz' in file:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
92 f = gzip.open(file,'rt')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
93 else:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
94 f = open(file,'rt')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
95 return f
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
96
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
97 except Exception as err:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
98 exc_type, exc_value, exc_tb = sys.exc_info()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
99 tbe = tb.TracebackException(
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
100 exc_type, exc_value, exc_tb,
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
101 )
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
102 print(''.join(tbe.format()),file=sys.stderr)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
103
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
104 def readrnaz(rnaz):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
105 try:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
106 toparse = readin(rnaz)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
107 tointersect = {}
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
108 header = []
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
109 for line in toparse:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
110 if '#' in line[0]:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
111 tointersect['header']=line.strip()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
112 line = re.sub('^#','',line)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
113 cont = line.strip().split('\t')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
114 foi = cont.index('seqID') # need to find which column contains seqID
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
115 sf = cont.index('start') # need to find which column contains start
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
116 ef = cont.index('end') # need to find which column contains end
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
117 if 'strand' in cont:# need to find which column contains strand
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
118 df = cont.index('strand')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
119 else:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
120 df = None
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
121 else:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
122 content = line.strip().split('\t')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
123 newid=re.split('\.|\,|\s|\\|\/|\_', content[foi])[1] # I can only hope that we have species.chromosome.whatever as annotation in aln or maf, if not this is hardly parseable
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
124 if df:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
125 longid = '_'.join([newid, content[sf], content[ef], 'RNAzresult', '0', content[df]])
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
126 tointersect[longid] = content
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
127 else:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
128 longid = '_'.join([newid, content[sf], content[ef], 'RNAzresult', '0', '+'])
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
129 tointersect[longid] = content
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
130 longid = '_'.join([newid, content[sf], content[ef], 'RNAzresult', '0', '-'])
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
131 tointersect[longid] = content
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
132
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
133 return tointersect
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
134
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
135 except Exception as err:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
136 exc_type, exc_value, exc_tb = sys.exc_info()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
137 tbe = tb.TracebackException(
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
138 exc_type, exc_value, exc_tb,
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
139 )
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
140 print(''.join(tbe.format()),file=sys.stderr)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
141
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
142
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
143 def rnaztobed(rnaz):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
144 try:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
145 tmpbed = []
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
146 for key in rnaz:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
147 if key != 'header':
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
148 tmpbed.append('\t'.join(key.split('_')))
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
149
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
150 return '\n'.join(tmpbed)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
151
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
152 except Exception as err:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
153 exc_type, exc_value, exc_tb = sys.exc_info()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
154 tbe = tb.TracebackException(
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
155 exc_type, exc_value, exc_tb,
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
156 )
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
157 print(''.join(tbe.format()),file=sys.stderr)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
158
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
159 def bedtornaz(bed, rnaz, bedout, rnazout):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
160 try:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
161 b = open(bedout,'w')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
162 r = open(rnazout,'w')
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
163
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
164 annotatedbed=[]
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
165 annotatedrnaz=[]
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
166 annotatedrnaz.append(str.join('\t',[rnaz['header'],'Annotation']))
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
167 for line in open(bed.fn):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
168 out = line.strip().split("\t")
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
169 annotatedbed.append(str.join('\t',out[0:3]+out[9:10]+out[4:6]))
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
170 key = str.join('_',out[0:6])
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
171 annotatedrnaz.append(str.join('\t',rnaz[key]+out[9:10]))
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
172
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
173 print(str.join('\n', annotatedbed),file=b)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
174 print(str.join('\n', annotatedrnaz),file=r)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
175
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
176 except Exception as err:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
177 exc_type, exc_value, exc_tb = sys.exc_info()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
178 tbe = tb.TracebackException(
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
179 exc_type, exc_value, exc_tb,
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
180 )
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
181 print(''.join(tbe.format()),file=sys.stderr)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
182
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
183
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
184 def closefile(file):
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
185 try:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
186 file.close()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
187
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
188 except Exception as err:
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
189 exc_type, exc_value, exc_tb = sys.exc_info()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
190 tbe = tb.TracebackException(
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
191 exc_type, exc_value, exc_tb,
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
192 )
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
193 print(''.join(tbe.format()),file=sys.stderr)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
194
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
195
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
196
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
197
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
198 ####################
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
199 #### MAIN ####
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
200 ####################
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
201 if __name__ == '__main__':
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
202 args=parseargs()
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
203 annotate(args.bed, args.input, args.bedout, args.rnazout)
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
204 ######################################################################
5d006d19f70a planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
205 # AnnotateRnaz.py ends here