Exemplo n.º 1
0
def runPipeClip(infile,outputPrefix,matchLength,mismatch,rmdup,fdrEnrichedCluster,clipType,fdrReliableMutation,species):
	myClip = CLIP.CLIP(infile,outputPrefix)
	logging.info("Start to run")
	if myClip.testInput():#check input
		logging.info("Input file OK,start to run PIPE-CLIP")
		logging.info("Species info %s" % species)
		if myClip.readfile():
			myClip.filter(matchLength,mismatch,clipType,rmdup,outputPrefix)
			myClip.printMutations()
			if len(myClip.clusters)>0:
				logging.info("Get enriched clusters")
				gc.collect()
				status = Enrich.clusterEnrich(myClip,fdrEnrichedCluster)
				if status:
					logging.info("Found %d enriched clusters" % myClip.sigClusterCount)
					myClip.printEnrichedClusters()
				else:
					logging.error("There is no enriched cluster found. Exit program")
					sys.exit(1)
			else:
				logging.error("There is no clusters found. Please check input.Exit program.")
				sys.exit(1)
			
			if len(myClip.mutations.keys())>0:
				logging.info("Get reliable mutations")
				Enrich.mutationEnrich(myClip,fdrReliableMutation)
				myClip.printReliableMutations()
			else:
				logging.warning("There is no mutation found in this BAM file.")
			#Start to get crosslinking sites
			if myClip.sigClusterCount > 0 and myClip.sigMutationCount>0:
				logging.info("Get cross-linking sites")
				myClip.getCrosslinking()
				if (len(myClip.crosslinking.keys())>0):
					outfilelist = myClip.printCrosslinkingSites()
					myClip.printCrosslinkingMutations()
				else:
					logging.warning("There is no crosslinking found. May be caused by no reliable mutations in enriched clusters. Print out enriched clusters instead.")
					outfilelist = myClip.printEnrichClusters()
			else:
				if myClip.sigClusterCount <= 0:
					logging.error("There is no enriched clusters for this sample, please check your input file. Exit.")
					sys.exit(2)
				elif myClip.sigMutationCount <=0:
					logging.warning("There is no reliable mutations found. PIPE-CLIP will provide enriched clusters as crosslinking candidates.")
					outfilelist = myClip.printEnrichClusters()
			#annotation if possible
		#logging.debug(outfilelist)
		if species in ["mm10","mm9","hg19"]:
			for name in outfilelist:
				#logging.debug("Start to do annotation for %s" % name)
				Utils.annotation(name,species)
	else:
		print >> sys.stderr, "File corruputed, program exit."
		sys.exit(0)
Exemplo n.º 2
0
	def fishertest(self):
		fp = Enrich.fisherTest(self.clusterP,self.mutationP)
		self.fisherP = fp