Exemplo n.º 1
0
    def testRun(self):

        self.ana = AnalysisFactory.createAnalysisFromModuleName(
            "ParallelMpileup")

        self.ana.setInputFiles(self.input_files, self.input_types)
        self.ana.refgenome = self.refgenome

        self.assertTrue(len(self.input_files) == 1)
        self.assertTrue(len(self.input_types) == 1)

        self.ana.init()

        cmds = self.ana.getCommands()

        print cmds

        self.assertTrue(len(cmds) == 2)

        runner = AnalysisRunner(self.ana)

        res = runner.run()

        self.assertTrue(res)

        self.ana.postProcessOutput()

        output_strings = self.ana.output_strings

        print output_strings

        for strobj in output_strings:
            print strobj.output_string

        self.assertTrue(len(output_strings) == 2)
    def testRun(self):

        self.ana = AnalysisFactory.createAnalysisFromModuleName("FastQC")

        self.ana.setInputFiles(self.input_files, self.input_types)

        self.assertTrue(len(self.input_files) == 1)
        self.assertTrue(len(self.input_types) == 1)

        cmds = self.ana.getCommands()

        print cmds

        self.assertTrue(len(cmds) == 1)

        runner = AnalysisRunner(self.ana)

        res = runner.run()

        self.assertTrue(res)

        self.ana.postProcessOutput()

        output_str = self.ana.output_str

        self.assertTrue(len(output_str) == 4)
Exemplo n.º 3
0
    def testRun(self):

        anarun = AnalysisRunner(self.ana)

        res = anarun.run()

        self.assertTrue(res)
Exemplo n.º 4
0
class ObjectCreateCheck(unittest.TestCase
                        ):  # Class with unitttest.TestCase as arg -
    def setUp(self):

        self.inputs = ['/tmp']

        self.anaobj = DirectoryListAnalysis()

    def testSetInputFiles(self):

        self.assertTrue(
            AnalysisUtils.setInputFiles(self.anaobj, self.inputs, ['dir']))

    def testGetInput(self):

        AnalysisUtils.setInputFiles(self.anaobj, self.inputs, ['dir'])

        tmpinputs = self.anaobj.input_files

        self.assertEqual(len(tmpinputs), len(
            self.inputs))  # Assertion that the test framework collates

    def testRun(self):

        AnalysisUtils.setInputFiles(self.anaobj, self.inputs, ['dir'])

        self.runner = AnalysisRunner(self.anaobj)

        self.runner.run()

        tmpstr = AnalysisUtils.getOutputStrings(self.anaobj)

        print tmpstr
        self.assertTrue(len(AnalysisUtils.getOutputStrings(self.anaobj)) > 0)

    def testGetOutput(self):
        AnalysisUtils.setInputFiles(self.anaobj, self.inputs, ['dir'])

        self.runner = AnalysisRunner(self.anaobj)

        self.runner.run()

        out = AnalysisUtils.getOutputStrings(self.runner.analysis)

        self.assertTrue(len(out) > 0)
Exemplo n.º 5
0
    def testGetOutput(self):
        anarun = AnalysisRunner(self.ana)

        res = anarun.run()

        anarun.analysis.postProcessOutput()

        out = anarun.analysis.output_files

        print out
        print anarun.analysis.summary_data

        self.assertTrue(len(out) == 2)
Exemplo n.º 6
0
    def testRunMummer(self):

        
        mummer = Mummer()

        self.assertTrue(mummer)
        self.assertTrue(AnalysisUtils.setInputFiles(mummer,self.input_files,['fasta','fasta']))

        runner = AnalysisRunner(mummer)
        

        self.assertTrue(runner.run())

        self.assertTrue(len(mummer.output_strings) == 1)

        self.assertTrue(mummer.output_strings[0].output_string.index('4: FINISHING DATA') > 0)


        self.assertTrue(FileUtils.fileExists('../testout/mummer.delta'))
Exemplo n.º 7
0
class AnalysisRunnerWrapper(object):

    def __init__(self,args):
        
        self.args   = args;
        self.dbobj  = AnalysisDBFactory(settings.DBNAME)

        logging.info("\n\nGot new analysis to run %30s\n\n"  % args.analysis);

        logging.info("%30s %15s is %20s"             % (args.analysis,"analysis",  args.analysis));
        logging.info("%30s %15s is %20s"             % (args.analysis,"input",     args.input));
        logging.info("%30s %15s is %20s"             % (args.analysis,"input_type", args.input_type));
        logging.info("%30s %15s is %20s"             % (args.analysis,"outdir",    args.outdir));
        logging.info("%30s %15s is %20s"             % (args.analysis,"param",     args.param));
        logging.info("%30s %15s is %20s"             % (args.analysis,"runtype",   args.runtype));
        logging.info("%30s %15s is %20s"             % (args.analysis,"queue",     args.queue));
        logging.info("%30s %15s is %20s"             % (args.analysis,"cores",     args.cores));
        logging.info("%30s %15s is %20s"             % (args.analysis,"mempercore",args.mempercore));


    def fetchLaunchableJobIDs(self,numjobs,analysis):

        self.dbfactory = AnalysisDBFactory(settings.DBNAME)

        return self.dbfactory.fetchLaunchableJobIDs(numjobs,analysis)

    def createAnalysisRunnerClassFromID(self,jobid):

        self.dbfactory = AnalysisDBFactory(settings.DBNAME)

        self.ana     = self.dbfactory.fetchAnalysisByID(jobid)

        logging.info("ANA FROM DB %s"%self.ana)

        self.ana.status = "LOADED_FROM_DB"
        self.dbfactory.saveAnalysis(self.ana)


    def createAnalysisRunnerClass(self):
        print self.args

        self.dbfactory = AnalysisDBFactory(settings.DBNAME)

        self.ana     = AnalysisFactory.createAnalysisFromModuleName(self.args.analysis)

        self.ana.setInputFiles     (self.args.input,self.args.input_type)

        self.ana.init()

        self.ana.setParameters     (self.args.param)
        self.dbfactory.saveAnalysis(self.ana)

         
    def run(self):

        #try:

            # Create the analysis runner which runs the commands and saves the output

            self.runner  = AnalysisRunner(self.ana)    

            self.dbfactory.updateAnalysisStatus(self.ana,"RUNNING")

            # Run the commands

            self.runner.run()

            self.dbfactory.current_status = "RUN_FINISHED"
            self.dbfactory.saveAnalysis(self.ana)

            # Post process the output including copying tmp files to final output directory

            self.dbfactory.updateAnalysisStatus(self.ana,"PROCESSING_OUTPUT")

            self.ana.postProcessOutput()

            self.dbfactory.current_status = "PROCESSED_OUTPUT"
            self.dbfactory.saveAnalysis(self.ana)

            # Set the final status and save the analysis to the db

            self.ana.current_status  = "ANALYSIS_FINISHED"
            self.dbfactory.saveAnalysis(self.ana)