コード例 #1
0
ファイル: AMP.py プロジェクト: bioaicuhksz/AMPfinder
    def process_contig(self):
        """Process nuclotide sequence(s)."""
        file_name = os.path.basename(self.input_sequence)
        output = self.output_file
        tax_class = self.tax_class
        print("OKOKOKOKOKOK")
        orf_obj = ORF(input_file=self.input_sequence)
        orf_obj.contig_to_orf()
        contig_fsa_file = os.path.join(self.working_directory,
                                       "{}.temp.contig.fsa".format(file_name))

        try:
            if os.stat(contig_fsa_file).st_size > 0:
                if self.aligner == "diamond":
                    diamond_obj = Diamond(input_file=contig_fsa_file,
                                          output_file=output,
                                          tax_class=tax_class,
                                          num_threads=self.threads)
                    diamond_obj.run()
                else:
                    print(contig_fsa_file)
                    blast_obj = Blast(input_file=contig_fsa_file,
                                      output_file=output,
                                      tax_class=tax_class,
                                      num_threads=self.threads)
                    blast_obj.run()
            else:
                self.write_stub_output_file()
        except Exception as e:
            pass
        else:
            pass
コード例 #2
0
ファイル: test_blast.py プロジェクト: Rory-McLeod/ENZA_Pc
 def test_interpertBlast(self):
     tempBlast = Blast("", "")
     tempBlast.makeDatabase("test_data/reference.fasta")
     tempBlast.aliasTool("test_data/reference.fasta", "test_data")
     tempBlast.query = "test_data/contigs_1.fasta"
     tempBlast.doBlast("test_data")
     tempBlast.interpertBlast("test_data")
     self.assertEqual(len(tempBlast.hitSet), 3)
コード例 #3
0
ファイル: Rps2blast.py プロジェクト: marieBvr/virAnnot
 def __init__(self, args):
     self.execution = 1
     self.check_args(args)
     bcontigfile = os.getcwd() + '/' + str(
         args['sample']) + '/' + args['bcontigs']
     if not os.path.exists(bcontigfile):
         self.csv_to_fasta()
     self.cmd = []
     self.ssh_cmd = []
     if self.execution == 1:
         Blast.create_cmd(self)
コード例 #4
0
ファイル: test_blast.py プロジェクト: Rory-McLeod/ENZA_Pc
 def test_makeDatabase(self):
     tempBlast = Blast("", "")
     tempBlast.makeDatabase("test_data/reference.fasta")
     workline = "blastdbcmd -db test_data/reference.fasta -info"
     p = subprocess.Popen(workline, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     try:
         stdout, stderr = p.communicate()
         testResult = True
         if p.returncode == 0:
             if "1 sequences; 10,000 total bases" not in stdout:
                 testResult = False
             self.assertTrue(testResult)
         else:
             raise EnvironmentError(stderr)
     except EnvironmentError as error:
         self.fail(error)
コード例 #5
0
ファイル: AMP.py プロジェクト: bioaicuhksz/AMPfinder
 def process_protein(self):
     """Process protein sequence(s)."""
     file_name = os.path.basename(self.input_sequence)
     output = self.output_file
     tax_class = self.tax_class
     if self.aligner == "diamond":
         diamond_obj = Diamond(self.input_sequence,
                               output_file=output,
                               tax_class=tax_class,
                               num_threads=self.threads)
         diamond_obj.run()
     else:
         blast_obj = Blast(input_file=file_name,
                           output_file=output,
                           tax_class=tax_class,
                           num_threads=self.threads)
         blast_obj.run()
コード例 #6
0
ファイル: test_blast.py プロジェクト: Rory-McLeod/ENZA_Pc
 def test_doBlast(self):
     tempBlast = Blast("", "")
     tempBlast.makeDatabase("test_data/reference.fasta")
     tempBlast.aliasTool("test_data/reference.fasta", "test_data")
     tempBlast.query = "test_data/contigs_1.fasta"
     tempBlast.doBlast("test_data")
     try:
         outputFile = open("test_data/blastResult.csv")
         testResult = True
         for line in outputFile:
             if "gi|49175990|ref|NC_000913.2|" not in line:
                 testResult = False
         self.assertTrue(testResult)
     except IOError as error:
         self.fail(error)
コード例 #7
0
ファイル: main.py プロジェクト: shenoisam/coronavirus
def main():

    # Define an argument parser to pull arguments from the command line
    parser = argparse.ArgumentParser(
        description='Run a local blast query on a variety of sequences.')

    # f1 argument
    parser.add_argument('-f',
                        metavar='-f',
                        nargs='+',
                        required=True,
                        help='A list of filenames or Refseq ids ')

    # f2 argument
    parser.add_argument('-g',
                        metavar='-g',
                        nargs='+',
                        required=True,
                        type=int,
                        help='Genomes passed by taxid: 9606, 562, 2697049')

    # Output file
    parser.add_argument('-o',
                        metavar='-o',
                        nargs='+',
                        required=True,
                        help='The name of the output file')

    # e value argument
    parser.add_argument('-e',
                        nargs='?',
                        default=10,
                        type=int,
                        help='e-value threshold. Defaults to 10.')

    # Parse arguments
    args = parser.parse_args()

    # Generate the blast object with the arguments
    blast = Blast(args)

    # Get the filenames of the query sequences needed
    filenames = blast.pull_sequences()

    # Run the blast query
    blast.format_file()
    blast.run_blast(filenames)
コード例 #8
0
FP1.close

expressions = []
FP2.readline()
for line in FP2:
    temp = line.strip().split()
    trID = temp[0]
    dShift = temp[1]
    hShock = temp[2]
    loggrowth = temp[3]
    pphase = temp[4]
    dxp = DiffExp(trID, dShift, hShock, loggrowth, pphase)
    expressions.append(dxp)
FP2.close

objblast = Blast(blast)
objmatrix = Matrix(expressions)

'''
Load the BlastHit objects that are good matches into a dictionary
'''
goodblasthits = {}
for item in objblast:
    if item.good_match():
        goodblasthits[item.TranscriptID] = item.SwissProtID

'''
create an output file
'''
FP3 = open("Output.txt", 'w')
FP3.write('{}\t{}\t{}\t{}\t{}\n'.format('','Sp_ds','Sp_hs', 'Sp_log', 'Sp_plat'))
コード例 #9
0
                    player1 = players.sprites()[0]
                    player1.money = pm
                    moneycounter = CounterDisplay(player1.money,
                                                  (20, height - 10))
                    healthbar = HealthBar(player1, (50, 50))

                if event.key == pygame.K_d or event.key == pygame.K_RIGHT:
                    player1.direction("right")
                if event.key == pygame.K_a or event.key == pygame.K_LEFT:
                    player1.direction("left")
                if event.key == pygame.K_w or event.key == pygame.K_UP:
                    player1.jump()
                if event.key == pygame.K_s or event.key == pygame.K_DOWN:
                    player1.direction("down")
                if event.key == pygame.K_SPACE:
                    Blast(player1.headingx, player1.rect.center)
            if event.type == pygame.KEYUP:
                if event.key == pygame.K_d or event.key == pygame.K_RIGHT:
                    player1.direction("stop right")
                if event.key == pygame.K_a or event.key == pygame.K_LEFT:
                    player1.direction("stop left")
                if event.key == pygame.K_w or event.key == pygame.K_UP:
                    player1.stop_jump()
                if event.key == pygame.K_s or event.key == pygame.K_DOWN:
                    player1.direction("stop down")

        playersHitBlocks = pygame.sprite.groupcollide(players, hardBlocks,
                                                      False, False)
        enemiesHitBlocks = pygame.sprite.groupcollide(enemies, hardBlocks,
                                                      False, False)
        enemiesHitEnemies = pygame.sprite.groupcollide(enemies, enemies, False,
コード例 #10
0
                                                               "/MapperUnique.gff"))
methodList.append(PrimerDesign.PrimerDesign.runMethodSubstract([methodList[1], methodList[2]], Main.Main.workDir +
                                                               "/DenovoUnique.gff"))
genome = PrimerDesign.PrimerDesign.readRefGenome(Main.Main.genomeAdd + Main.Main.refGenomeList[0])
blastList = list()
for PipMethod in methodList:
    fastaFile = PipMethod.rstrip()[:-3]+"fa"
    PrimerDesign.PrimerDesign.saveFasta(fastaFile, PrimerDesign.PrimerDesign.readGFF(PipMethod, genome))
    blastList.append(fastaFile)

otherGenomes = copy.copy(Main.Main.refGenomeList)
del otherGenomes[0]
blastThread = list()
allAlias = ""
for genome in otherGenomes:
   Blast.makeDatabase(str(genome), Main.Main.workDir)
   allAlias += Main.Main.workDir + "/" + genome + " "
allAlias = allAlias.rstrip()
Blast.aliasTool(allAlias, Main.Main.workDir)
for blastItem in blastList:
    blastResult = Blast(blastItem, otherGenomes)
    blastResult.start()
    blastThread.append(blastResult)

for blastItem in blastThread:
    blastItem.join()

genome = PrimerDesign.PrimerDesign.readRefGenome(Main.Main.genomeAdd + Main.Main.refGenomeList[0])
for k, blastItem in enumerate(blastList):
    item = blastItem.rstrip()[:-2]
    thread = threading.Thread(PrimerDesign.PrimerDesign.generatePrimer3Input(
コード例 #11
0
ファイル: Rps2blast.py プロジェクト: marieBvr/virAnnot
 def create_genouest_script(self):
     Blast.create_genouest_script(self)