comparison seg2matrix/segToMatrixGalaxy.py @ 54:59dbe857f5d4

introduce normal_CNV parameter
author jingchunzhu
date Thu, 17 Sep 2015 22:03:04 -0700
parents 7de3db823f90
children bf57076e27b9
comparison
equal deleted inserted replaced
53:7de3db823f90 54:59dbe857f5d4
31 self.chrom_end = chrom_end 31 self.chrom_end = chrom_end
32 self.strand = "." 32 self.strand = "."
33 33
34 34
35 if __name__ == "__main__": 35 if __name__ == "__main__":
36 if len(sys.argv[:])!= 5: 36 if len(sys.argv[:])!= 6:
37 print "python segToMatrixGalaxy.py inputSegmentFile refGeneFile outputMatrix outputProbeMap\n" 37 print "python segToMatrixGalaxy.py inputSegmentFile refGeneFile outputMatrix outputProbeMap NORMAL_CNV\n"
38 sys.exit() 38 sys.exit()
39 seg = CGData.GenomicSegment.GenomicSegment() 39 seg = CGData.GenomicSegment.GenomicSegment()
40 seg.load(sys.argv[1]) 40 seg.load(sys.argv[1])
41 41
42 refgene = CGData.RefGene.RefGene() 42 refgene = CGData.RefGene.RefGene()
43 refgene.load(sys.argv[2]) 43 refgene.load(os.path.dirname(sys.argv[0])+"/"+os.path.basename(sys.argv[2]))
44 # refgene.load(os.path.dirname(sys.argv[0])+"/"+sys.argv[2]) 44
45 NORMAL_CNV = sys.argv[5]
45 46
46 handle = open(sys.argv[3], "w") 47 handle = open(sys.argv[3], "w")
47 m = matrix_write(handle) 48 m = matrix_write(handle)
48 CGData.SegToMatrix.seg_to_matrix(seg, m) 49 CGData.SegToMatrix.seg_to_matrix(seg, m, NORMAL_CNV)
49 handle.close() 50 handle.close()
50 51
51 handle = open(sys.argv[4], "w") 52 handle = open(sys.argv[4], "w")
52 probeMapper = CGData.GeneMap.ProbeMapper('b') 53 probeMapper = CGData.GeneMap.ProbeMapper('b')
53 handle.write("%s\t%s\t%s\t%s\t%s\t%s\n" % ("#id", "gene","chrom","chromStart","chromEnd","strand")) 54 handle.write("%s\t%s\t%s\t%s\t%s\t%s\n" % ("id", "gene","chrom","chromStart","chromEnd","strand"))
54 for probe in m.probes: 55 for probe in m.probes:
55 hits = [] 56 hits = []
56 for hit in probeMapper.find_overlap( probe, refgene ): 57 for hit in probeMapper.find_overlap( probe, refgene ):
57 if hit.name not in hits: 58 if hit.name not in hits:
58 hits.append(hit.name) 59 hits.append(hit.name)