def run_transdecoder_longorfs(self, infasta, out_dir=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): if not pu.check_files_exist(infasta): pu.print_boldred("Please check input file:" + infasta) if not out_dir: out_dir = os.getcwd() newOpts = {"-t": infasta, "-O": out_dir} mergedOpts = {**newOpts, **kwargs} #execute LongOrfs status = self.run_transdecoder('TransDecoder.LongOrfs', verbose=verbose, quiet=quiet, logs=logs, objectid=objectid, **mergedOpts) if not status: pu.print_boldred("Transdecoder failed") return "" return out_dir
def run_trinity(self,valid_args_list=None,verbose=False,quiet=False,logs=True,objectid="NA",**kwargs): """Wrapper for running trinity Parameters ---------- valid_args: list list of valid arguments verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. kwargs: dict Options passed to trinity :return: Return the status of trinity command. :rtype: bool """ trinity_cmd=['Trinity'] #add options trinity_cmd.extend(pu.parse_unix_args(valid_args_list,kwargs)) #start ececution status=pe.execute_command(trinity_cmd,verbose=verbose,quiet=quiet,logs=logs,objectid=objectid) if not status: pu.print_boldred("trinity failed") #return status return status
def check_dependencies(dependencies): """Check whether specified programs exist in the environment. This uses the which command to test whether a program is present. Parameters ---------- dependencies: list list of programs to test :return: True is all dependencies are satified, False otherwise. :rtype: bool """ errorFlag = False for s in dependencies: #print_blue("Checking "+s+"...") thisCmd = ['which', s] if (getReturnStatus(thisCmd)): #print_green ("Found "+s) pass else: pu.print_boldred("Can not find " + s) errorFlag = True if errorFlag: return False return True
def init_from_accession(self,srr_accession,directory): """ Create SRA object using provided srr accession and directory, where data is downloaded/saved This functions inits srrid, and paths to srr/fastq if they already exist thus will not be downloaded again """ #check if programs exist self.dep_list=['prefetch',"fasterq-dump"] if not pe.check_dependencies(self.dep_list): raise OSError("ERROR: Please install missing programs.") if not srr_accession: raise ValueError("Please provide a valid accession") if not directory: directory=os.getcwd() #create a dir named <srr_accession> and use as directory self.directory=os.path.join(directory,self.srr_accession) #sra file be stored here #self.sra_path=os.path.join(self.directory,self.srr_accession+".sra") #check if fastq files exist if not self.search_fastq(self.directory): #download sra and run fqdump if not self.download_sra(): pu.print_boldred('prefetch failed!!! Trying fasterq-dump...') #run fasterqdump either on downloaded SRA file or direclty return self.download_fastq() return True
def run_bbduk(self, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper to run bbduk.sh """ #override existing arguments mergedArgsDict = {**self.passedArgumentDict, **kwargs} #create command to run bbduk_cmd = ["bbduk.sh"] #bbduk.sh follows java style arguments bbduk_cmd.extend(pu.parse_java_args(self.valid_args, mergedArgsDict)) #start ececution status = pe.execute_command(bbduk_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("bbduk failed") #return status return status
def run_bbsplit(self,objectid="NA",**kwargs): """wrapper to run bbsplit :return: Status of bbsplit command :rtype: bool """ bbsplit_args=['ref','ref_x','build','path','in','in1','in2','outu','outu2','outu1','qin','interleaved', 'maxindel','minratio','minhits','ambiguous','ambiguous2', 'qtrim','untrim','out_','basename','bs','scafstats', 'refstats','nzo','-Xmx','-eoom','-da'] #create command to run bbsp_cmd=["bbsplit.sh"] #bbduk.sh follows java style arguments bbsp_cmd.extend(pu.parse_java_args(bbsplit_args,kwargs)) #start ececution status=pe.execute_command(bbsp_cmd,objectid=objectid) if not status: pu.print_boldred("bbsplit failed") #return status return status
def search_sra(self, path): """Search .sra file under a dir Return True if found otherwise False """ #search files under the path sra_files = pe.find_files(path, "*.sra") if len(sra_files) < 1: return False if len(sra_files) > 1: pu.print_boldred( "Found multiple .sra files. Using the first entry...") sra_path = sra_files[0] #self.location=path self.srr_accession = pu.get_file_basename(sra_path) self.localSRAFilePath = sra_path self.sraFileSize = pu.get_file_size(self.localSRAFilePath) #test if file is paired or single end if pe.is_paired(self.localSRAFilePath): self.layout = "PAIRED" else: self.layout = "SINGLE" pu.print_green("Found .sra " + self.localSRAFilePath) return True
def runMikado(self, sub_command, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper to run mikado """ #override existing arguments mergedArgsDict = {**self.passedArgumentDict, **kwargs} mikado_Cmd = ['mikado', sub_command] #add options mikado_Cmd.extend(pe.parse_unix_args(self.valid_args, mergedArgsDict)) #print("Executing:"+" ".join(mergedArgsDict)) #start ececution status = pe.execute_command(mikado_Cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("mikado failed") #return status return status
def runMikado(self, sub_command, valid_args=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper to run mikado """ valid_commands = [ 'configure', 'prepare', 'serialise', 'pick', 'compare' ] if sub_command not in valid_commands: pu.print_boldred("Invalid command: " + sub_command + ". Exiting...") return False mikado_Cmd = ['mikado', sub_command] #add options mikado_Cmd.extend(pu.parse_unix_args(valid_args, kwargs)) #print("Executing:"+" ".join(mergedArgsDict)) #start ececution status = pe.execute_command(mikado_Cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("mikado failed") #return status return status
def search_fastq(self, path): """Search .fastq file under a dir and create SRA object Return True if found otherwise False """ #search files under the path fq_files = pe.find_files(path, "*.fastq") if len(fq_files) < 1: return False if len(fq_files) > 2: pu.print_boldred("Can not determine .fastq. Exiting...") return False fq_files.sort() #case with single fastq if len(fq_files) == 1: self.localfastqPath = fq_files[0] pu.print_green("Found .fastq " + self.localfastqPath) self.layout = "SINGLE" #case with paired fastq if len(fq_files) == 2: self.localfastq1Path = fq_files[0] self.localfastq2Path = fq_files[1] pu.print_green("Found .fastq " + self.localfastq1Path + " " + self.localfastq2Path) self.layout = "PAIRED" #self.location=path #self.srr_accession=pu.get_file_basename(fq_files[0]) return True
def build_index(self, in_fasta, dbname, out_dir=None, threads=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Build a diamond index and store its path in self """ #check input files if not pu.check_files_exist(in_fasta): pu.print_boldred( "Input fasta: {} not found...\n diamond makedb failed".format( in_fasta)) return False #create out_dir if not out_dir: out_dir = os.getcwd() if not pu.check_paths_exist(out_dir): pu.mkdir(out_dir) #check if index already exists index_path = os.path.join(out_dir, dbname) self.index = index_path if self.check_index(): pu.print_green("Diamond index: {} exists, using it...".format( self.index)) self.index = index_path return True if not threads: threads = self.threads newOpts = { "--in": in_fasta, "-d": index_path, "--threads": str(threads) } #add input files to kwargs, overwrite newOpts with kwargs mergedOpts = {**newOpts, **kwargs} #call run_diamond status = self.run_diamond("makedb", verbose=verbose, quiet=quiet, logs=logs, objectid=objectid, **mergedOpts) if status: self.index = index_path return True return False
def get_read_length(self,lines_to_examine=None): """Examine first lines_to_examine lines and return the mode of read lengths returns int """ if _dryrun: return 100 if not lines_to_examine: lines_to_examine=4*10000 else: lines_to_examine=4*lines_to_examine if not self.fastq_exists(): pu.print_boldred("Fastq files don't exist") return 0 #check the read len if self.layout=='SINGLE': with open(self.fastq_path) as f: data=[next(f) for x in range(lines_to_examine)] reads_lens=[] for i in range(1,len(data),4): reads_lens.append(len(data[i].strip())) return statistics.mode(reads_lens) if self.layout=='PAIRED': reads_lens=[] with open(self.fastq_path) as f: data=[next(f) for x in range(lines_to_examine)] #get lens from first file for i in range(1,len(data),4): reads_lens.append(len(data[i].strip())) mode1=statistics.mode(reads_lens) #print("Mode:",mode1) return mode1 """ Not sure how to deal with unqeual read lengths #read 2nd file reads_lens=[] with open(self.fastq2_path) as f: data=[next(f) for x in range(lines_to_examine)] #get lens from second file for i in range(1,len(data),4): reads_lens.append(len(data[i].strip())) mode2=statistics.mode(reads_lens) print("Mode:",mode2) return (mode1+mode2)/2 """ return 0
def run_cuff(self, command, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running cuff* commands Parameters ---------- command: string the command name verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. kwargs: dict Options passed to command :return: Returns the status of the command. :rtype: bool """ validCommands = [ 'cuffcompare', 'cuffdiff', 'cufflinks', 'cuffmerge', 'cuffnorm', 'cuffquant' ] if command in validCommands: #override existing arguments merged_args_dict = {**self.passed_args_dict, **kwargs} cuff_cmd = [command] #add options cuff_cmd.extend( pu.parse_unix_args(self.valid_args_list, merged_args_dict)) #start ececution status = pe.execute_command(cuff_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("cufflinks failed") #return status return status else: pu.print_boldred("Unknown command {}" + command) return False
def run_salmon(self, subcommand, valid_args=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running salmon. Parameters ---------- subcommand: str subcommand for salmon valid_args: list List of valid arguments verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to salmon. This will override the existing options :return: Returns the status of salmon. True is passed, False if failed. :rtype: bool """ #check for a valid index if subcommand != "index": if not self.check_index(): raise Exception( "ERROR: Invalid salmon index. Please run build index to generate an index." ) salmon_Cmd = ['salmon', subcommand] salmon_Cmd.extend(pu.parse_unix_args(valid_args, kwargs)) #start ececution status = pe.execute_command(salmon_Cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid, command_name=" ".join(salmon_Cmd[0:2])) if not status: pu.print_boldred("salmon failed") return status
def __init__(self, *args, index=None, genome=None, threads=None, **kwargs): """ init Hisat2 object Parameters ---------- *args : tuple Positional arguements index : Str, optional Path to Hisat index. If index is not present it will generate an index using the genome. Index can be supplied via the hisat2.yaml file too. The default is None. genome : Str, optional Path to the reference genome. This will be used to build an index if index is not present The default is None. threads : int, optional Threads to use for hisat2. This will override the global --threads parameter supplied to pyrpipe. The default is None. **kwargs : dict keyword arguments Raises ------ ValueError Raises ValueError if hisat index is not found and genome is not present to generate an index. Returns ------- None. """ super().__init__(*args, **kwargs) self._command = 'hisat2' self._deps = [self._command, 'samtools'] self.index = index self.genome = genome self._param_yaml = 'hisat2.yaml' self._valid_args = valid_args._args_HISAT2 #resolve threads to use self.resolve_parameter("-p", threads, _threads, '_threads') #resolve index to use self.resolve_parameter("-x", index, index, 'index') #check index if not self.check_index(): if not (pu.check_files_exist(self.genome)): pu.print_boldred( "Hisat2 index '{}' not found; New index could not be created as genome file '{}' not found." .format(self.index, self.genome)) raise ValueError( "Please provide a valid Hisat2 index, or a valid fasta file to generate the index" ) else: #call build index to generate index self.build_index(self.index, self.genome)
def run_star(self, valid_args=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running star. The self.star_index index used. Parameters ---------- valid_args: list List of valid arguments verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to stringtie. This will override the existing options in self.passed_args_dict (only replace existing arguments and not replace all the arguments). kwargs: dict arguments to pass to star. :return: Returns the status of star. True is passed, False if failed. :rtype: bool """ #check for a valid index if not self.check_index(): raise Exception( "ERROR: Invalid star index. Please run build index to generate an index." ) star_cmd = ['STAR'] #add options star_cmd.extend(pu.parse_unix_args(valid_args, kwargs)) #execute command cmd_status = pe.execute_command(star_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not cmd_status: pu.print_boldred("STAR failed:" + " ".join(star_cmd)) #return status return cmd_status
def __init__(self,srr_accession=None, directory=None, fastq=None,fastq2=None,sra=None): #these attributes can be associated with an sra object self.fastq_path=fastq self.fastq2_path=fastq2 self.sra_path=sra self.srr_accession=srr_accession self.layout=None if not self.init_object(srr_accession, directory, fastq,fastq2,sra): pu.print_boldred("ERROR: Creating SRA object") raise ValueError("Please check fastq files {} {}".format(fastq,fastq2))
def run_portcullis(self, sub_command, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """ Wrapper to run portcullis. Parameters ---------- sub_command: string sub_command to pass to portcullis e.g. full, prep, junc etc. verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict arguments to pass to portcullis. This will override parametrs already existing in the self.passedArgumentDict list but NOT replace them. :return: Returns the status of portcullis. True is passed, False if failed. :rtype: bool """ #override existing arguments mergedArgsDict = {**self.passedArgumentDict, **kwargs} portcullis_cmd = ['portcullis', sub_command] #add options portcullis_cmd.extend( pu.parse_unix_args(self.valid_args, mergedArgsDict)) print("Executing:" + " ".join(portcullis_cmd)) #start ececution status = pe.execute_command(portcullis_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("portcullis failed") #return status return status
def runtest(): failed = False sraob = sra.SRA('ERR726985', directory='./pyrpipe_sratest') if not sraob.fastq_exists(): pu.print_boldred('Test failed') failed = True pu.print_notification('Cleaning up...') sraob.delete_fastq() os.rmdir(sraob.directory) if failed: pu.print_boldred('Paired end test failed') failed = False sraob = sra.SRA('SRR2134545', directory='./pyrpipe_sratest') if not sraob.fastq_exists(): pu.print_boldred('Test failed') failed = True pu.print_notification('Cleaning up...') sraob.delete_fastq() os.rmdir(sraob.directory) if failed: pu.print_boldred('Single end test failed') failed = False if not failed: pu.print_green( '\n#####################All Tests Passed#####################\n') os.rmdir('./pyrpipe_sratest')
def build_index(self,index_path,index_name,fasta,verbose=False,quiet=False,logs=True,objectid="NA",**kwargs): """Function to build kallisto index index_path: str path to the output directory index_name: str index name verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to kallisto. This will override the existing options in self.passed_args_dict (only replace existing arguments and not replace all the arguments). :return: Status of kallisto index :rtype: bool """ #check input if not pu.check_files_exist(fasta): pu.print_boldred("{} does not exist. Exiting".format(fasta)) return False #create out dir if not pu.check_paths_exist(index_path): if not pu.mkdir(index_path): print("ERROR in building kallisto index. Failed to create index directory.") return False indexOut=os.path.join(index_path,index_name) newOpts={"--":(fasta,),"-i":indexOut} mergedOpts={**kwargs,**newOpts} #call salmon status=self.run_kallisto("index",verbose=verbose,quiet=quiet,logs=logs,objectid=objectid,**mergedOpts) if status: #check if sam file is present in the location directory of sra_object if pu.check_files_exist(indexOut): self.kallisto_index=indexOut self.passedArgumentDict['-i']=self.kallisto_index pu.print_green("kallisto_index is:"+self.kallisto_index) return True else: pu.print_boldred("Failed to create kallisto index") return False
def build_index(self,index_path,index_name,fasta,verbose=False,quiet=False,logs=True,objectid="NA",**kwargs): """ build salmon index and store the path to index in self index_path: str path to the output directory index_name: str index name verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to salmon. This will override the existing options :return: status of salmon index :rtype: bool """ #check input if not pu.check_files_exist(fasta): pu.print_boldred("{} does not exist. Exiting".format(fasta)) return False #create out dir if not pu.check_paths_exist(index_path): if not pu.mkdir(index_path): print("ERROR in building hisat2 index. Failed to create index directory.") return False indexOut=os.path.join(index_path,index_name) newOpts={"-t":fasta,"-i":indexOut} mergedOpts={**kwargs,**newOpts} #call salmon status=self.run_salmon("index",verbose=verbose,quiet=quiet,logs=logs,objectid=objectid,**mergedOpts) if status: #check if sam file is present in the location directory of sra_object #if check_files_exist(os.path.join(indexOut,"versionInfo.json")): #not sure if this is reliable if pu.check_paths_exist(indexOut): self.salmon_index=indexOut self.passedArgumentDict['-i']=self.salmon_index pu.print_green("salmon index is:"+self.salmon_index) return True pu.print_boldred("Failed to create salmon index") return False
def run_samtools(self, sub_command, valid_args=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """A wrapper to run samtools. Parameters ---------- sub_command: string sub_command to pass to samtools e.g. sort, merge etc valid_args: list A list containing valid parameters. Parameters in kwargs not in this list will be ignored. Default: None arg1: dict arguments to pass to samtools. verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to samtools. This will override the existing options :return: Returns the status of samtools. True is passed, False if failed. :rtype: bool """ samtools_cmd = ['samtools', sub_command] #add options samtools_cmd.extend(pu.parse_unix_args(valid_args, kwargs)) #start ececution status = pe.execute_command(samtools_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("samtools failed") #return status return status
def run_bowtie2(self, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running bowtie2. ---------- verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to stringtie. This will override the existing options in self.passed_args_dict (only replace existing arguments and not replace all the arguments). kwargs: dict arguments to pass to bowtie2. This will override parametrs already existing in the self.passedArgumentList list but NOT replace them. :return: Returns the status of bowtie2. True is passed, False if failed. :rtype: bool """ #check for a valid index if not self.check_index(): raise Exception( "ERROR: Invalid Bowtie2 index. Please run build index to generate an index." ) #override existing arguments mergedArgsDict = {**self.passedArgumentDict, **kwargs} bowtie2_cmd = ['bowtie2'] bowtie2_cmd.extend(pu.parse_unix_args(self.valid_args, mergedArgsDict)) #print("Executing:"+" ".join(bowtie2_cmd)) #start ececution status = pe.execute_command(bowtie2_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("bowtie2 failed") return status
def perform_quant(self,sra_object,out_dir="",verbose=False,quiet=False,logs=True,objectid="NA",**kwargs): """Run kallisto quant sra_object: SRA SRA object contatining paths to fastq files index_path: str path to the output directory index_name: str index name verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to kallisto. This will override the existing options :return: Path to kallisto out directory :rtype: string """ if not out_dir: out_dir=os.path.join(sra_object.location,"kallisto_out") if sra_object.layout == 'PAIRED': newOpts={"-o":out_dir,"--":(sra_object.localfastq1Path,sra_object.localfastq2Path)} else: newOpts={"-o":out_dir,"--single":"", "--":(sra_object.localfastqPath,)} #add input files to kwargs, overwrite kwargs with newOpts mergedOpts={**kwargs,**newOpts} #call salmon status=self.run_kallisto("quant",verbose=verbose,quiet=quiet,logs=logs,objectid=sra_object.srr_accession,**mergedOpts) if status: #check if sam file is present in the location directory of sra_object if pu.check_files_exist(os.path.join(out_dir,"abundance.tsv")): return out_dir pu.print_boldred("kallisto quant failed") return ""
def run_portcullis(self, sub_command, valid_args=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """ Wrapper to run portcullis. Parameters ---------- sub_command: string sub_command to pass to portcullis e.g. full, prep, junc etc. valid_args: list A list of valid arguments. Arguments outside this list will be ignored. If empty or None, accepts all arguments. verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict arguments to pass to portcullis. :return: Returns the status of portcullis. True is passed, False if failed. :rtype: bool """ portcullis_cmd = ['portcullis', sub_command] #add options portcullis_cmd.extend(pu.parse_unix_args(valid_args, kwargs)) #start ececution status = pe.execute_command(portcullis_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("portcullis failed") #return status return status
def run_bowtie2(self, valid_args=None, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running bowtie2. valid_args: list list of valid args verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict arguments to pass to bowtie2. :return: Returns the status of bowtie2. True is passed, False if failed. :rtype: bool """ #check for a valid index if not self.check_index(): raise Exception( "ERROR: Invalid Bowtie2 index. Please run build index to generate an index." ) bowtie2_cmd = ['bowtie2'] bowtie2_cmd.extend(pu.parse_unix_args(valid_args, kwargs)) #print("Executing:"+" ".join(bowtie2_cmd)) #start ececution status = pe.execute_command(bowtie2_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("bowtie2 failed") return status
def run_trimgalore(self, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running trimgalore Parameters ---------- verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to trimgalore (will override existing parameters) :return: Status of trimgalore command :rtype: bool """ #override existing arguments mergedArgsDict = {**self.passedArgumentDict, **kwargs} #create command to run trimgalore_cmd = ['trim_galore'] trimgalore_cmd.extend( pu.parse_unix_args(self.valid_args, mergedArgsDict)) #start ececution status = pe.execute_command(trimgalore_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("trimgalore failed") #return status return status
def run_stringtie(self, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running stringtie. This can be used to run stringtie without using perform_assembly() function. Parameters ---------- verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. This is useful for debugging, benchmarking and reports. kwargs: dict Options to pass to stringtie. This will override the existing options in self.passed_args_dict (only replace existing arguments and not replace all the arguments). :return: Returns the status of stringtie command. :rtype: bool """ #override existing arguments merged_args_dict = {**self.passed_args_dict, **kwargs} stie_cmd = ['stringtie'] #add options stie_cmd.extend( pu.parse_unix_args(self.valid_args_list, merged_args_dict)) #start ececution status = pe.execute_command(stie_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("stringtie failed") #return status return status
def check_dependencies(dependencies): """Check whether specified programs exist in the environment. This uses the which command to test whether a program is present. Parameters ---------- dependencies: list list of programs to test :return: True is all dependencies are satified, False otherwise. :rtype: bool """ for tool in dependencies: if not which(tool): pu.print_boldred("ERROR. {} command not found".format(tool)) return False return True
def run_cufflinks(self, verbose=False, quiet=False, logs=True, objectid="NA", **kwargs): """Wrapper for running cufflinks Parameters ---------- verbose: bool Print stdout and std error quiet: bool Print nothing logs: bool Log this command to pyrpipe logs objectid: str Provide an id to attach with this command e.g. the SRR accession. kwargs: dict Options passed to cufflinks :return: Returns the status of cufflinks command. :rtype: bool """ #override existing arguments merged_args_dict = {**self.passed_args_dict, **kwargs} cufflinks_cmd = ['cufflinks'] #add options cufflinks_cmd.extend( pu.parse_unix_args(self.valid_args_list, merged_args_dict)) #start ececution status = pe.execute_command(cufflinks_cmd, verbose=verbose, quiet=quiet, logs=logs, objectid=objectid) if not status: pu.print_boldred("cufflinks failed") #return status return status