Exemple #1
0
    def getCommands(self):

        AnalysisUtils.checkDiskSpace(self)

        if AnalysisUtils.checkInputFiles(self) == False:
            raise Exception("Input files [%s] don't exist = can't continue" %
                            (self.input_files))

        command = "java -Xmx1024M -Djava.awt.headless=true -Djava.awt.headlesslib=true -classpath " + self.classpath + " " + " -Dfastqc.output_dir=" + self.working_dir + " uk.ac.babraham.FastQC.FastQCApplication " + self.input_files[
            0].input_file

        self.commands.append(
            AnalysisCommand(command=command,
                            command_rank=len(self.commands) + 1))

        return self.commands
Exemple #2
0
    def getCommands(self):

        if self.commands and len(self.commands) > 0:
            return self.commands

        logging.info(" ========> Analysis %20s Getting commands" % (self.name))

        self.commands = []
        self.expected_output_files = []
        self.temp_output_files = []

        outdir = self.output_dir
        tmpdir = self.working_dir

        btbin = self.bowtiebindir + self.bowtiebinname
        stbin = self.samtoolsbindir + self.samtoolsbinname

        self.calculateSpaceNeeded()

        if FileUtils.fileExists(btbin) == False:
            raise Exception("Binary file [%s] doesn't exist = can't continue" %
                            btbin)

        if FileUtils.fileExists(stbin) == False:
            raise Exception("Binary file [%s] doesn't exist = can't continue" %
                            stbin)

        if AnalysisUtils.checkInputFiles(self) == False:
            raise Exception("Input files [%s] don't exist = can't continue" %
                            (self.input_files))

        AnalysisUtils.checkDiskSpace(self)

        for fobj in self.input_files:
            f = fobj.input_file
            try:

                if f.endswith(".gz"):
                    #  f = "<( zcat -c " + f + " )"
                    tmpf = f.replace(".gz", "")
                    fparts = FileUtils.getFileParts(tmpf)
                    command = "gunzip -c " + f + " > " + tmpdir + "/" + fparts[
                        'basename']
                    self.commands.append(command)
                    self.temp_output_files.append(tmpf)
                    f = tmpdir + "/" + fparts['basename']

                fparts = FileUtils.getFileParts(f)
                fstub = fparts['filestub']

                bowtieoutfile = tmpdir + "/" + fstub + ".sam"
                samtoolsoutfile = tmpdir + "/" + fstub + ".bam"

                if self.param == None:
                    raise Exception(
                        "No parameters entered for bowtie = needs -x <genomeindex>"
                    )

                command1 = btbin + " " + self.param + " " + f + " | " + stbin + " view -bS - | " + stbin + " sort - " + tmpdir + "/" + fstub

                logging.info(" ========> Analysis %20s command 1 : %s" %
                             (self.name, command1))

                #command2 = stbin + " view -bS " + bowtieoutfile + "| " + stbin + " sort - " + tmpdir + "/" + fstub

                #                logging.info(" ========> Analysis %20s command 2 : %s" % (self.name,command2))

                command2 = stbin + " index " + samtoolsoutfile

                logging.info(" ========> Analysis %20s command 3 : %s" %
                             (self.name, command2))

                # self.expected_output_files.append(fstub + ".sam")
                self.expected_output_files.append(
                    AnalysisExpectedOutputFile(expected_output_file=fstub +
                                               ".bam"))
                self.expected_output_files.append(
                    AnalysisExpectedOutputFile(expected_output_file=fstub +
                                               ".bam.bai"))

                self.commands.append(AnalysisCommand(command=command1))
                self.commands.append(AnalysisCommand(command=command2))
                #self.commands.append(command3)

            except Exception as e:
                logging.info(
                    " ========> Analysis %20s Failed building command list [%s]"
                    % (self.name, e))
                raise

        return self.commands