예제 #1
0
    def testRunBlastX(self):
        """
        test running blastx
        """

        ## run the blast
        self.blast = Blast(self.queryFile)
        outFile = "adh-0-2.xml"
        targetDB = os.path.join(self.BLASTDB, "uniprot_sprot")
        start, stop = 0, 2
        self.blast.run_blast(targetDB,
                             evalue=0.1,
                             start=start,
                             stop=stop,
                             cmd='blastx')

        ## read the blast
        parser = ParseBlast(outFile)
        parser.run()

        ## clean up
        for fn in [
                "adh-0-2_parsed.csv", "adh-0-2_parsed.log", "adh-0-2.fasta",
                "adh-0-2.xml"
        ]:
            self.assertTrue(os.path.exists(fn))
            os.remove(fn)
예제 #2
0
    def parse_file(self,resultsFilePath):
        """
        use ParseBlast to parse a given xml formatted file
        """

        print '...parsing', resultsFilePath
        parser = ParseBlast(resultsFilePath,fhLog=self.logWriter,fhResults=self.resultsWriter)
        parser.run()
예제 #3
0
파일: BlastTest.py 프로젝트: xflicsu/htsint
    def testRunBlastX(self):
        """
        test running blastx
        """

        ## run the blast
        self.blast = Blast(self.queryFile)
        outFile = "adh-0-2.xml"
        targetDB = os.path.join(self.BLASTDB, "uniprot_sprot")
        start, stop = 0, 2
        self.blast.run_blast(targetDB, evalue=0.1, start=start, stop=stop, cmd="blastx")

        ## read the blast
        parser = ParseBlast(outFile)
        parser.run()

        ## clean up
        for fn in ["adh-0-2_parsed.csv", "adh-0-2_parsed.log", "adh-0-2.fasta", "adh-0-2.xml"]:
            self.assertTrue(os.path.exists(fn))
            os.remove(fn)
## read input
if len(sys.argv) < 2:
    raise Exception("\n\nInvalid syntax. use '%s'" % sys.argv[0] +
                    " -s source\n")

try:
    optlist, args = getopt.getopt(sys.argv[1:], 's:')
except getopt.GetoptError:
    raise Exception("\n\nInvalid syntax. use '%s'" % sys.argv[0] +
                    " -s source\n")

source = 'None'
for o, a in optlist:
    if o == '-s':
        source = a

if source not in ['dn', 'gg', 'reference']:
    raise Exception("bad source specified")

outfmt = '5'
blastFile = "blast-%s.%s" % (source, "outfmt" + outfmt)
outFile = "blast-%s-parsed.csv" % source

if not os.path.exists(blastFile):
    raise Exception("cannot find blast output file: %s" % blastFile)

## parse the resultsread the blast
parser = ParseBlast(blastFile, outFile=outFile)
parser.run()