Beispiel #1
0
def profileTargets(tccList, cName, dir=None, min=0):
    if not dir:
        dir = 'out'

    cg.clearDirectory(dir)  #clear and/or make

    for tcc in tccList:
        plot.plotASProfile(tcc, cName, directory=dir, min=min)
def profileTargets(tccList, cName, dir = None, min = 0):
	if not dir:
		dir = 'out'
		
	cg.clearDirectory(dir) #clear and/or make
		
	for tcc in tccList:
		plot.plotASProfile(tcc, cName, directory = dir, min = min)
Beispiel #3
0
def writeWigFromHitDict(hitDict, assembly, name, directory=None):

    mConf = c.getConfig('Main.conf')
    if not directory: directory = mConf.conf['wigs']
    if not name: name = cg.getBaseFileName(name, naked=True)
    lDict = cg.returnChromLengthDict(assembly)

    cg.clearDirectory(directory, overwrite=False)
    #write results to wig file
    for chrom in hitDict:
        for strand in hitDict[chrom]:

            oF = open(directory + '/%s.%s.%s.wig' % (name, chrom, strand), 'w')
            oF.write('track type=bedGraph name=%s.%s.%s\n' %
                     (name, chrom, strand))

            #print '  sorting'
            #print hitDict[chrom]
            chromEnd = lDict[chrom]  #
            hitDict[chrom][strand][chromEnd] = 0
            keys = hitDict[chrom][strand].keys()
            keys.sort()

            #print '  writing blocks'
            prevVal = 0
            prevCoord = 0
            blockStart = 0
            blockEnd = 1
            for key in keys:
                val = hitDict[chrom][strand][key]

                if prevCoord == key - 1:
                    if val == prevVal:  #should be combined
                        blockEnd = key + 1
                    else:  #no zero block
                        #write old block
                        oF.write('%s\t%s\t%s\t%s\n' %
                                 (chrom, blockStart, blockEnd,
                                  prevVal))  #!make it a float value?
                        #start new block
                        blockStart = key
                        blockEnd = key + 1

                else:
                    #write old block
                    oF.write('%s\t%s\t%s\t%s\n' %
                             (chrom, blockStart, blockEnd, prevVal))
                    #write zero block
                    oF.write('%s\t%s\t%s\t%s\n' % (chrom, blockEnd, key, 0))
                    #start new block
                    blockStart = key
                    blockEnd = key + 1

                prevVal = val
                prevCoord = key
            oF.close()
Beispiel #4
0
def writeWigFromHitDict(hitDict, assembly, name, directory = None):
	
	mConf = c.getConfig('Main.conf')
	if not directory: directory = mConf.conf['wigs']
	if not name: name = cg.getBaseFileName(name, naked = True)
	lDict = cg.returnChromLengthDict(assembly)
	
	cg.clearDirectory(directory, overwrite = False)
	#write results to wig file
	for chrom in hitDict:
		for strand in hitDict[chrom]:
			
			oF = open(directory + '/%s.%s.%s.wig' % (name, chrom, strand), 'w')
			oF.write('track type=bedGraph name=%s.%s.%s\n' % (name, chrom, strand))
			
			#print '  sorting'
			#print hitDict[chrom]
			chromEnd = lDict[chrom] #
			hitDict[chrom][strand][chromEnd] = 0
			keys = hitDict[chrom][strand].keys()
			keys.sort()
			
			#print '  writing blocks'
			prevVal = 0
			prevCoord = 0
			blockStart = 0
			blockEnd = 1
			for key in keys:
				val = hitDict[chrom][strand][key]
				
				if prevCoord == key - 1: 
					if val == prevVal:#should be combined
						blockEnd = key + 1
					else: #no zero block
						#write old block
						oF.write('%s\t%s\t%s\t%s\n' % (chrom, blockStart, blockEnd, prevVal)) #!make it a float value?
						#start new block
						blockStart = key
						blockEnd = key + 1
						
				else:
					#write old block
					oF.write('%s\t%s\t%s\t%s\n' % (chrom, blockStart, blockEnd, prevVal))
					#write zero block
					oF.write('%s\t%s\t%s\t%s\n' % (chrom, blockEnd, key, 0))
					#start new block
					blockStart = key
					blockEnd = key + 1
				
				prevVal = val
				prevCoord = key
			oF.close()
Beispiel #5
0
def plotResults(fN, cName=None):

    cHairs = getHairpins.getHairpins(fN)  #CID: HAIRPIN

    directory = cg.getBaseFileName(fN)
    cg.clearDirectory(directory)

    #change the directory before plotting
    cwd = os.getcwd()
    os.chdir(directory)

    for CID in cHairs:
        print 'plotting:', CID
        cgPlot.plotASProfile(cHairs[CID], cName)

    os.chdir(cwd)
def plotResults(fN, cName = None):
		
	cHairs = getHairpins.getHairpins(fN) #CID: HAIRPIN
	
	directory = cg.getBaseFileName(fN)
	cg.clearDirectory(directory)
	
	#change the directory before plotting
	cwd = os.getcwd()
	os.chdir(directory)
	
	for CID in cHairs:
		print 'plotting:', CID
		cgPlot.plotASProfile(cHairs[CID], cName)
	
	os.chdir(cwd)