comparison SMART/Java/Python/CompareOverlappingSmallQuery.py @ 55:2ac71607aa60

Uploaded
author m-zytnicki
date Fri, 10 Jan 2014 08:59:23 -0500
parents 169d364ddd91
children
comparison
equal deleted inserted replaced
54:7f0e49595f31 55:2ac71607aa60
72 self.invert = False 72 self.invert = False
73 self.antisense = False 73 self.antisense = False
74 self.collinear = False 74 self.collinear = False
75 self.pcOverlapQuery = False 75 self.pcOverlapQuery = False
76 self.pcOverlapRef = False 76 self.pcOverlapRef = False
77 self.minOverlap = False
77 self.bins = {} 78 self.bins = {}
78 self.overlaps = {} 79 self.overlaps = {}
79 self.notOverlapping = False 80 self.notOverlapping = False
80 81
81 def setReferenceFile(self, fileName, format): 82 def setReferenceFile(self, fileName, format):
104 self.antisense = boolean 105 self.antisense = boolean
105 106
106 def setMinPercentOverlap(self, pcOverlapQuery, pcOverlapRef): 107 def setMinPercentOverlap(self, pcOverlapQuery, pcOverlapRef):
107 self.pcOverlapQuery = pcOverlapQuery 108 self.pcOverlapQuery = pcOverlapQuery
108 self.pcOverlapRef = pcOverlapRef 109 self.pcOverlapRef = pcOverlapRef
110
111 def setMinOverlap(self, minOverlap):
112 self.minOverlap = minOverlap
109 113
110 def includeNotOverlapping(self, boolean): 114 def includeNotOverlapping(self, boolean):
111 self.notOverlapping = boolean 115 self.notOverlapping = boolean
112 116
113 def loadQuery(self): 117 def loadQuery(self):
132 if not queryTranscript.overlapWithExon(refTranscript): 136 if not queryTranscript.overlapWithExon(refTranscript):
133 return False 137 return False
134 if self.collinear and queryTranscript.getDirection() != refTranscript.getDirection(): 138 if self.collinear and queryTranscript.getDirection() != refTranscript.getDirection():
135 return False 139 return False
136 if self.antisense and queryTranscript.getDirection() == refTranscript.getDirection(): 140 if self.antisense and queryTranscript.getDirection() == refTranscript.getDirection():
141 return False
142 if self.minOverlap and not queryTranscript.overlapWithExon(refTranscript, self.minOverlap):
137 return False 143 return False
138 querySize = queryTranscript.getSize() 144 querySize = queryTranscript.getSize()
139 if self.pcOverlapQuery and not queryTranscript.overlapWithExon(refTranscript, int(querySize * self.pcOverlapQuery / 100.0)): 145 if self.pcOverlapQuery and not queryTranscript.overlapWithExon(refTranscript, int(querySize * self.pcOverlapQuery / 100.0)):
140 return False 146 return False
141 refSize = refTranscript.getSize() 147 refSize = refTranscript.getSize()
221 parser.add_option("-d", "--distance", dest="distance", action="store", default=0, type="int", help="accept some distance between query and reference [format: int]") 227 parser.add_option("-d", "--distance", dest="distance", action="store", default=0, type="int", help="accept some distance between query and reference [format: int]")
222 parser.add_option("-c", "--collinear", dest="collinear", action="store_true", default=False, help="provide collinear features [format: bool] [default: false]") 228 parser.add_option("-c", "--collinear", dest="collinear", action="store_true", default=False, help="provide collinear features [format: bool] [default: false]")
223 parser.add_option("-a", "--antisense", dest="antisense", action="store_true", default=False, help="provide antisense features [format: bool] [default: false]") 229 parser.add_option("-a", "--antisense", dest="antisense", action="store_true", default=False, help="provide antisense features [format: bool] [default: false]")
224 parser.add_option("-p", "--pcOverlapQuery", dest="pcOverlapQuery", action="store", default=False, type="int", help="min. % overlap of the query [format: bool] [default: false]") 230 parser.add_option("-p", "--pcOverlapQuery", dest="pcOverlapQuery", action="store", default=False, type="int", help="min. % overlap of the query [format: bool] [default: false]")
225 parser.add_option("-P", "--pcOverlapRef", dest="pcOverlapRef", action="store", default=False, type="int", help="min. % overlap of the reference [format: bool] [default: false]") 231 parser.add_option("-P", "--pcOverlapRef", dest="pcOverlapRef", action="store", default=False, type="int", help="min. % overlap of the reference [format: bool] [default: false]")
232 parser.add_option("-m", "--minOverlap", dest="minOverlap", action="store", default=False, type="int", help="min. # overlap between query and reference [format: bool] [default: false]")
226 parser.add_option("-x", "--exclude", dest="exclude", action="store_true", default=False, help="invert the match [format: bool] [default: false]") 233 parser.add_option("-x", "--exclude", dest="exclude", action="store_true", default=False, help="invert the match [format: bool] [default: false]")
227 parser.add_option("-v", "--verbosity", dest="verbosity", action="store", default=1, type="int", help="trace level [format: int]") 234 parser.add_option("-v", "--verbosity", dest="verbosity", action="store", default=1, type="int", help="trace level [format: int]")
228 (options, args) = parser.parse_args() 235 (options, args) = parser.parse_args()
229 236
230 cosq = CompareOverlappingSmallQuery(options.verbosity) 237 cosq = CompareOverlappingSmallQuery(options.verbosity)
234 cosq.includeNotOverlapping(options.notOverlapping) 241 cosq.includeNotOverlapping(options.notOverlapping)
235 cosq.setDistance(options.distance) 242 cosq.setDistance(options.distance)
236 cosq.setCollinear(options.collinear) 243 cosq.setCollinear(options.collinear)
237 cosq.setAntisense(options.antisense) 244 cosq.setAntisense(options.antisense)
238 cosq.setMinPercentOverlap(options.pcOverlapQuery, options.pcOverlapRef) 245 cosq.setMinPercentOverlap(options.pcOverlapQuery, options.pcOverlapRef)
246 cosq.setMinOverlap(options.minOverlap)
239 cosq.setInvert(options.exclude) 247 cosq.setInvert(options.exclude)
240 cosq.run() 248 cosq.run()