annotate SMART/Java/Python/RestrictFromCoverage.py @ 71:d96f6c9a39e0 draft default tip

Removed pyc files.
author m-zytnicki
date Thu, 07 Apr 2016 09:25:18 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 #! /usr/bin/env python
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 # Copyright INRA-URGI 2009-2012
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 # This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 # abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 # modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 # license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 # "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 # As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 # modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 # with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 # economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 # liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 # In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 # with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 # software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 # that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 # therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 # professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 # encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 # requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 # data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 # same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 # The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 # knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 import os, struct, time, random
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 from optparse import OptionParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 from commons.core.parsing.ParserChooser import ParserChooser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 from commons.core.writer.Gff3Writer import Gff3Writer
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 from SMART.Java.Python.structure.Transcript import Transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 from SMART.Java.Python.structure.Interval import Interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 from SMART.Java.Python.ncList.NCList import NCList
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 from SMART.Java.Python.ncList.NCListCursor import NCListCursor
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 from SMART.Java.Python.ncList.NCListFilePickle import NCListFilePickle, NCListFileUnpickle
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 from SMART.Java.Python.ncList.FileSorter import FileSorter
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 from SMART.Java.Python.misc.Progress import Progress
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 from SMART.Java.Python.misc.UnlimitedProgress import UnlimitedProgress
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 from SMART.Java.Python.misc import Utils
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 import cPickle as pickle
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 except:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 import pickle
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 REFERENCE = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 QUERY = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 TYPES = (REFERENCE, QUERY)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 TYPETOSTRING = {0: "reference", 1: "query"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 class RestrictFromCoverage(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 def __init__(self, verbosity = 1):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 self._verbosity = verbosity
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 self._randomNumber = random.randint(0, 100000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 self._nbWritten = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 self._nbLines = dict([type, 0] for type in TYPES)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 self._splittedFileNames = dict([type, {}] for type in TYPES)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 self._nbElementsPerChromosome = dict([type, {}] for type in TYPES)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 self._nbElements = dict([type, 0] for type in TYPES)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 def __del__(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 pass
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 def _close(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 self._writer.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 def setInputFileName(self, fileName, format, type):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 chooser = ParserChooser(self._verbosity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 chooser.findFormat(format)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 parser = chooser.getParser(fileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 sortedFileName = "%s_%d_%d_sorted.pkl" % (os.path.splitext(fileName)[0], self._randomNumber, type)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 if self._verbosity > 2:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 print "Preparing %s file..." % (TYPETOSTRING[type])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 startTime = time.time()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 fs = FileSorter(parser, self._verbosity-1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 fs.perChromosome(True)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 fs.setOutputFileName(sortedFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 fs.sort()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 self._nbLines[type] = fs.getNbElements()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 self._splittedFileNames[type] = fs.getOutputFileNames()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 self._nbElementsPerChromosome[type] = fs.getNbElementsPerChromosome()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 self._nbElements[type] = fs.getNbElements()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 endTime = time.time()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 if self._verbosity > 2:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 print " ...done (%ds)" % (endTime - startTime)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 def setOutputFileName(self, outputFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 self._writer = Gff3Writer(outputFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 def setPercent(self, minPercent, maxPercent):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 self._minPercent = minPercent
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 self._maxPercent = maxPercent
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 def setNbNucleotides(self, minNb, maxNb):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 self._minNucleotides = minNb
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 self._maxNucleotides = maxNb
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 def setOverlap(self, minOverlap, maxOverlap):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 self._minOverlap = minOverlap
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 self._maxOverlap = maxOverlap
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 def setStrands(self, boolean):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 self._twoStrands = boolean
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 def _compareChromosome(self, chromosome):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 firstOverlap = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 parser1 = NCListFileUnpickle(self._splittedFileNames[QUERY][chromosome], self._verbosity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 parser2 = NCListFileUnpickle(self._splittedFileNames[REFERENCE][chromosome], self._verbosity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 progress = Progress(self._nbElementsPerChromosome[QUERY][chromosome], "Analyzing %s" % (chromosome), self._verbosity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 for transcript1 in parser1.getIterator():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 firstOverlap = self._compareList(transcript1, parser2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 parser2.setInitAddress(firstOverlap)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 progress.inc()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 progress.done()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 def _compareList(self, transcript1, parser2):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 values = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 for exon in transcript1.getExons():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 values.append([0.0] * exon.getSize())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 firstOverlap = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 for transcript2 in parser2.getIterator():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 address = parser2.getCurrentTranscriptAddress()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 nbElements = float(transcript2.getTagValue("nbElements")) if "nbElements" in transcript2.getTagNames() else 1.0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 nbOccurrences = float(transcript2.getTagValue("nbOccurrences")) if "nbOccurrences" in transcript2.getTagNames() else 1.0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 nbElements /= nbOccurrences
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 if transcript2.getStart() > transcript1.getEnd():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 if firstOverlap == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 firstOverlap = address
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 if self._checkValues(values):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 self._printTranscript(transcript1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 return firstOverlap
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 elif transcript1.overlapWith(transcript2):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 if firstOverlap == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 firstOverlap = address
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 values = self._compareTranscript(transcript1, transcript2, values, nbElements)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 if self._checkValues(values):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 self._printTranscript(transcript1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 return firstOverlap
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 def _compareTranscript(self, transcript1, transcript2, values, nbElements):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 if not transcript1.overlapWith(transcript2) or ((self._twoStrands) and transcript1.getDirection() != transcript2.getDirection()):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 return values
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 for id1, exon1 in enumerate(transcript1.getExons()):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 for exon2 in transcript2.getExons():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 values[id1] = map(sum, zip(values[id1], self._compareExon(exon1, exon2, nbElements)))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150 return values
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 def _compareExon(self, exon1, exon2, nbElements):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 array = [0.0] * exon1.getSize()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 if not exon1.overlapWith(exon2) or ((self._twoStrands) and exon1.getDirection() != exon2.getDirection()):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 return array
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 for pos in range(max(exon1.getStart(), exon2.getStart()) - exon1.getStart(), min(exon1.getEnd(), exon2.getEnd()) - exon1.getStart()+1):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 array[pos] += nbElements
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 return array
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 def _filter(self, value):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 if self._minOverlap and self._maxOverlap:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 return self._minOverlap <= value <= self._maxOverlap
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 if self._minOverlap:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 return self._minOverlap <= value
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 if self._maxOverlap:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 return value <= self._maxOverlap
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 return True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 def _checkValues(self, values):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 nbValues = sum(map(len, values))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 nbPosValues = sum(map(len, [filter(self._filter, valuePart) for valuePart in values]))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 ratio = float(nbPosValues) / nbValues * 100
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 if self._minNucleotides and nbPosValues < self._minNucleotides:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 if self._maxNucleotides and nbPosValues > self._maxNucleotides:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 if self._minPercent and ratio < self._minPercent:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 if self._maxPercent and ratio > self._maxPercent:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 return True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 def _printTranscript(self, transcript):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 self._writer.addTranscript(transcript)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 self._nbWritten += 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 def run(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 for chromosome in sorted(self._splittedFileNames[QUERY].keys()):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 self._compareChromosome(chromosome)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 self._close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 if self._verbosity > 0:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 print "# queries: %d" % (self._nbElements[QUERY])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 print "# refs: %d" % (self._nbElements[REFERENCE])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 print "# written: %d (%d%%)" % (self._nbWritten, 0 if self._nbElements[QUERY] == 0 else round(float(self._nbWritten) / self._nbElements[QUERY] * 100))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 if __name__ == "__main__":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 description = "Restrict From Coverage v1.0.0: Select the elements from the first set which have a given coverage. [Category: Data Comparison]"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 parser = OptionParser(description = description)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 parser.add_option("-i", "--input1", dest="inputFileName1", action="store", type="string", help="input file 1 [compulsory] [format: file in transcript format given by -f]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 parser.add_option("-f", "--format1", dest="format1", action="store", type="string", help="format of file 1 [compulsory] [format: transcript file format]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 parser.add_option("-j", "--input2", dest="inputFileName2", action="store", type="string", help="input file 2 [compulsory] [format: file in transcript format given by -g]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 parser.add_option("-g", "--format2", dest="format2", action="store", type="string", help="format of file 2 [compulsory] [format: transcript file format]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 parser.add_option("-o", "--output", dest="output", action="store", default=None, type="string", help="output file [compulsory] [format: output file in GFF3 format]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 parser.add_option("-n", "--minNucleotides", dest="minNucleotides", action="store", default=None, type="int", help="minimum number of nucleotides overlapping to declare an overlap [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 parser.add_option("-N", "--maxNucleotides", dest="maxNucleotides", action="store", default=None, type="int", help="maximum number of nucleotides overlapping to declare an overlap [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 parser.add_option("-p", "--minPercent", dest="minPercent", action="store", default=None, type="int", help="minimum percentage of nucleotides overlapping to declare an overlap [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 parser.add_option("-P", "--maxPercent", dest="maxPercent", action="store", default=None, type="int", help="maximum percentage of nucleotides overlapping to declare an overlap [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 parser.add_option("-e", "--minOverlap", dest="minOverlap", action="store", default=None, type="int", help="minimum number of elements from 2nd file to declare an overlap [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 parser.add_option("-E", "--maxOverlap", dest="maxOverlap", action="store", default=None, type="int", help="maximum number of elements from 2nd file to declare an overlap [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 parser.add_option("-s", "--strands", dest="strands", action="store_true", default=False, help="consider the two strands separately [format: bool] [default: false]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 parser.add_option("-v", "--verbosity", dest="verbosity", action="store", default=1, type="int", help="trace level [format: int]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 (options, args) = parser.parse_args()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 rfc = RestrictFromCoverage(options.verbosity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 rfc.setInputFileName(options.inputFileName1, options.format1, QUERY)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 rfc.setInputFileName(options.inputFileName2, options.format2, REFERENCE)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 rfc.setOutputFileName(options.output)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 rfc.setNbNucleotides(options.minNucleotides, options.maxNucleotides)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 rfc.setPercent(options.minPercent, options.maxPercent)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 rfc.setOverlap(options.minOverlap, options.maxOverlap)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 rfc.setStrands(options.strands)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 rfc.run()