def getRunStatement(self, infile, outfile, controlfile): """ Generate a specific run statement for each peakcaller class """ # select location of the spp script to run if self.PARAMS_PEAKCALLER["spp_options_idr_script"] == "default": executable = P.which("run_spp.R") elif self.PARAMS_PEAKCALLER["spp_options_idr_script"] == "nodups": executable = P.which("run_spp_nodups.R") else: executable = self.PARAMS_PEAKCALLER["spp_options_idr_script"] try: os.path.exists(executable) except: raise IOError("SPP script not found: %s" % executable) # select the threshold for lax peak calling if self.PARAMS_PEAKCALLER["spp_options_npeaks"]: if self.PARAMS_PEAKCALLER["spp_options_fdr"]: raise Exception("Value specified for both SPP options" " -npeaks and -fdr please select one or" " other option, but not both") else: threshold = "-npeaks=" + \ str(self.PARAMS_PEAKCALLER["spp_options_npeaks"]) elif self.PARAMS_PEAKCALLER["spp_options_fdr"]: threshold = "-fdr=" + \ str(self.PARAMS_PEAKCALLER["spp_options_fdr"]) else: raise Exception("Must specify a value for either" " spp_options_npeaks or spp_options_fdr," " but not both") # build run statement for spp. # -savn is output.npeak.file (passed as NULL, # means filename based on infile) # -out is output.result.file # -odir defaults to os.path.dirname( infile ) # -savn is save narrowpeak file # -savr is save regionpeak file # (run_spp.R script throws an error if region peak is not output). statement = [("Rscript %(executable)s" " -c=%(infile)s" " -i=%(controlfile)s" " %(threshold)s" " -savn" " -savr")] # add additional options statement.append(self.PARAMS_PEAKCALLER["spp_options_parameters"]) # specify outfile statement.append(" -rf" " -out=/stats/phantomPeakStatsReps.tab" " >& %(outfile)s") statement = (" ".join(statement) % locals()) return statement
def runControlCPC(infile, outfile): # farm.py is called from within cpc.sh assert P.which("farm.py"), "farm.py needs to be in $PATH for cpc to run" # Default cpc parameters don't work with later versions of blast E.info("Running cpc with blast version:%s" % P.which("blastx")) result_evidence = P.snip(outfile, ".result") + ".evidence" working_dir = "lncRNA_control/cpc" statement = ("%(scriptsdir)s/cpc.sh" " %(infile)s" " %(outfile)s" " %(working_dir)s" " %(result_evidence)s") P.run()