comparison seg2matrix/segToMatrixGalaxy.py @ 60:bf57076e27b9 default tip

change genomicSegment input data
author jingchunzhu@gmail.com
date Tue, 27 Oct 2015 16:07:09 -0700
parents 59dbe857f5d4
children
comparison
equal deleted inserted replaced
59:b88b95642f59 60:bf57076e27b9
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import sys,os 3 import sys,os, string
4 import CGData.GenomicSegment 4 import CGData.GenomicSegment
5 import CGData.SegToMatrix 5 import CGData.SegToMatrix
6 import CGData.RefGene 6 import CGData.RefGene
7 import CGData.GeneMap 7 import CGData.GeneMap
8 8
13 self.probes = [] 13 self.probes = []
14 def write(self, s): 14 def write(self, s):
15 self.buff += s 15 self.buff += s
16 if s.endswith("\n"): 16 if s.endswith("\n"):
17 tmp = self.buff.split("\t") 17 tmp = self.buff.split("\t")
18 if tmp[0] != "probe": 18 if string.strip(tmp[0]) != "probe":
19 tmp2 = tmp[0].split("_") 19 tmp2 = tmp[0].split("_")
20 p = probeseg(tmp[0], tmp2[0], int(tmp2[1]), int(tmp2[2])) 20 p = probeseg(tmp[0], tmp2[0], int(tmp2[1]), int(tmp2[2]))
21 self.probes.append(p) 21 self.probes.append(p)
22 22
23 self.handle.write(self.buff) 23 self.handle.write(self.buff)
29 self.chrom = chrom 29 self.chrom = chrom
30 self.chrom_start = chrom_start 30 self.chrom_start = chrom_start
31 self.chrom_end = chrom_end 31 self.chrom_end = chrom_end
32 self.strand = "." 32 self.strand = "."
33 33
34
35 if __name__ == "__main__": 34 if __name__ == "__main__":
36 if len(sys.argv[:])!= 6: 35 if len(sys.argv[:])!= 6:
37 print "python segToMatrixGalaxy.py inputSegmentFile refGeneFile outputMatrix outputProbeMap NORMAL_CNV\n" 36 print "python segToMatrixGalaxy.py inputSegmentFile refGeneFile outputMatrix outputProbeMap NORMAL_CNV\n"
38 sys.exit() 37 sys.exit()
39 seg = CGData.GenomicSegment.GenomicSegment() 38 seg = CGData.GenomicSegment.GenomicSegment()
40 seg.load(sys.argv[1]) 39 seg.load(sys.argv[1])
41 40
42 refgene = CGData.RefGene.RefGene() 41 refgene = CGData.RefGene.RefGene()
43 refgene.load(os.path.dirname(sys.argv[0])+"/"+os.path.basename(sys.argv[2])) 42 refgene.load(os.path.dirname(sys.argv[0])+"/"+os.path.basename(sys.argv[2]))
44 43
45 NORMAL_CNV = sys.argv[5] 44 NORMAL_CNV = sys.argv[5]
46 45