| 0 | 1 # ----------------------------------------------------------------------# | 
|  | 2 # Copyright (c) 2011, Richard Lupat & Jason Li. | 
|  | 3 # | 
|  | 4 # > Source License < | 
|  | 5 # This file is part of CONTRA. | 
|  | 6 # | 
|  | 7 #    CONTRA is free software: you can redistribute it and/or modify | 
|  | 8 #    it under the terms of the GNU General Public License as published by | 
|  | 9 #    the Free Software Foundation, either version 3 of the License, or | 
|  | 10 #    (at your option) any later version. | 
|  | 11 # | 
|  | 12 #    CONTRA is distributed in the hope that it will be useful, | 
|  | 13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 15 #    GNU General Public License for more details. | 
|  | 16 # | 
|  | 17 #    You should have received a copy of the GNU General Public License | 
|  | 18 #    along with CONTRA.  If not, see <http://www.gnu.org/licenses/>. | 
|  | 19 # | 
|  | 20 # | 
|  | 21 #-----------------------------------------------------------------------# | 
|  | 22 # Last Updated : 28 Mar 2011 11:00AM | 
|  | 23 | 
|  | 24 class Target: | 
|  | 25 	""" | 
|  | 26 	Class for target regions | 
|  | 27 	""" | 
|  | 28 | 
|  | 29 	population = 0 | 
|  | 30 | 
|  | 31 	def __init__(self): | 
|  | 32 		self.id = 0 | 
|  | 33 		self.gene = "unknown" | 
|  | 34 		self.chr = "chr1" | 
|  | 35 		self.start = 0 | 
|  | 36 		self.end = 0 | 
|  | 37 		self.numberExon = 0 | 
|  | 38 		self.oriStart = 0 | 
|  | 39 		self.oriEnd = 0 | 
|  | 40 | 
|  | 41 def convertTarget(target): | 
|  | 42 	targets = open(target) | 
|  | 43 | 
|  | 44 	targetList = [] | 
|  | 45 | 
|  | 46 	count = 0 | 
|  | 47 	for region in targets: | 
|  | 48 		region = region.split() | 
|  | 49 		chr = "chr" + region[0].strip("chr") | 
|  | 50 		start = region[1] | 
|  | 51 		end = region[2] | 
|  | 52 		try: | 
|  | 53 			gene = region[3] | 
|  | 54 		except: | 
|  | 55 			gene = "unknown" | 
|  | 56 		count += 1 | 
|  | 57 | 
|  | 58 		aTarget = Target() | 
|  | 59 		aTarget.id = count | 
|  | 60 		aTarget.gene = gene | 
|  | 61 		aTarget.chr  = chr | 
|  | 62 		aTarget.start = start | 
|  | 63 		aTarget.end = end | 
|  | 64 		aTarget.numberExon = 1 | 
|  | 65 		aTarget.oriStart = start | 
|  | 66 		aTarget.oriEnd	 = end | 
|  | 67 | 
|  | 68 		targetList.append(aTarget) | 
|  | 69 | 
|  | 70 | 
|  | 71 	return targetList |