annotate AnnotateRNAz.py @ 4:58fd61a8362e 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:13:28 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
58fd61a8362e 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 ---
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
2 #
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
4 # Description:
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
6 # Maintainer:
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
8 # Version:
58fd61a8362e 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: ()
58fd61a8362e 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)
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
13 # URL:
58fd61a8362e 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:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
15 # Keywords:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
16 # Compatibility:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
17 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
18 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
19
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
20 # Commentary:
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
25
58fd61a8362e 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:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
27 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
28 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
29 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
30 #
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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.
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
35 #
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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.
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
40 #
58fd61a8362e 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
58fd61a8362e 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/>.
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
43 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
44 #
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
45
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
46 # Code:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
47
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
49
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
59
58fd61a8362e 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():
58fd61a8362e 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')
58fd61a8362e 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')
58fd61a8362e 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')
58fd61a8362e 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')
58fd61a8362e 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')
58fd61a8362e 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()
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
67
58fd61a8362e 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):
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
69 try:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
70
58fd61a8362e 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
58fd61a8362e 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)
58fd61a8362e 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)
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
75
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
77
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
79
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
81
58fd61a8362e 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:
58fd61a8362e 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()
58fd61a8362e 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(
58fd61a8362e 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,
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
86 )
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
88
58fd61a8362e 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):
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
90 try:
58fd61a8362e 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:
58fd61a8362e 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')
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
93 else:
58fd61a8362e 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')
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
96
58fd61a8362e 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:
58fd61a8362e 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()
58fd61a8362e 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(
58fd61a8362e 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,
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
101 )
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
103
58fd61a8362e 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):
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
105 try:
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
107 tointersect = {}
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
108 header = []
58fd61a8362e 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:
58fd61a8362e 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]:
58fd61a8362e 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()
58fd61a8362e 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)
58fd61a8362e 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')
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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
58fd61a8362e 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')
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
119 else:
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
121 else:
58fd61a8362e 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')
58fd61a8362e 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
58fd61a8362e 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:
58fd61a8362e 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]])
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
127 else:
58fd61a8362e 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', '+'])
58fd61a8362e 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
58fd61a8362e 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', '-'])
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
132
58fd61a8362e 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
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
134
58fd61a8362e 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:
58fd61a8362e 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()
58fd61a8362e 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(
58fd61a8362e 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,
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
139 )
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
141
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
142
58fd61a8362e 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):
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
144 try:
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
145 tmpbed = []
58fd61a8362e 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:
58fd61a8362e 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':
58fd61a8362e 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('_')))
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
149
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
151
58fd61a8362e 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:
58fd61a8362e 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()
58fd61a8362e 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(
58fd61a8362e 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,
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
156 )
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
158
58fd61a8362e 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):
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
160 try:
58fd61a8362e 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')
58fd61a8362e 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')
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
163
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
164 annotatedbed=[]
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
165 annotatedrnaz=[]
58fd61a8362e 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']))
58fd61a8362e 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):
58fd61a8362e 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")
58fd61a8362e 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]))
58fd61a8362e 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])
58fd61a8362e 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]))
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
172
58fd61a8362e 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)
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
175
58fd61a8362e 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:
58fd61a8362e 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()
58fd61a8362e 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(
58fd61a8362e 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,
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
180 )
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
182
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
183
58fd61a8362e 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):
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
185 try:
58fd61a8362e 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()
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
187
58fd61a8362e 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:
58fd61a8362e 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()
58fd61a8362e 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(
58fd61a8362e 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,
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
192 )
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
194
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
195
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
196
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
197
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
198 ####################
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
199 #### MAIN ####
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
200 ####################
58fd61a8362e 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__':
58fd61a8362e 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()
58fd61a8362e 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)
58fd61a8362e planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_team/rnaz commit d261ddb93500e1ea309845fa3989c87c6312583d-dirty
bgruening
parents:
diff changeset
204 ######################################################################
58fd61a8362e 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