예제 #1
0
 def run_alignment(self, clean=True, consensus=True):
     # dialign requires ENV variable be set for dialign_dir
     mafft = which("mafft")
     # create results file
     fd, aln = tempfile.mkstemp(suffix='.mafft')
     os.close(fd)
     aln_stdout = open(aln, 'w')
     # dialign makes an extra file for fasta output
     #fasta = "{}.{}".format(aln, 'fa')
     # run MUSCLE on the temp file
     cmd = [mafft, "--auto", self.input]
     # just pass all ENV params
     proc = subprocess.Popen(cmd,
             stderr=subprocess.PIPE,
             stdout=aln_stdout
         )
     stderr = proc.communicate()
     aln_stdout.close()
     self.alignment = AlignIO.read(open(aln, 'rU'), "fasta", \
             alphabet=Gapped(IUPAC.unambiguous_dna, "-"))
     # build a dumb consensus
     if consensus:
         self.alignment_summary, self.alignment_consensus = \
             self._alignment_summary(self.alignment)
     # cleanup temp files
     if clean:
         self._clean(aln)
예제 #2
0
 def run_alignment(self, clean=True, consensus=True):
     # dialign requires ENV variable be set for dialign_dir
     daln = which("dialign2-2")
     daln = os.path.join(os.path.split(daln)[0], 'dialign2_dir')
     os.environ["DIALIGN2_DIR"] = "/Users/bcf/Bin/dialign2_dir/"
     # create results file
     fd, aln = tempfile.mkstemp(suffix='.dialign')
     os.close(fd)
     # dialign makes an extra file for fasta output
     fasta = "{}.{}".format(aln, 'fa')
     # run MUSCLE on the temp file
     cmd = ["dialign2-2", "-fa", "-fn", aln, "-n", self.input]
     # just pass all ENV params
     proc = subprocess.Popen(cmd,
             stderr=subprocess.PIPE,
             stdout=subprocess.PIPE,
             env=os.environ
         )
     stdout, stderr = proc.communicate()
     self.alignment = AlignIO.read(open(fasta, 'rU'), "fasta", \
             alphabet=Gapped(IUPAC.unambiguous_dna, "-"))
     # build a dumb consensus
     if consensus:
         self.alignment_summary, self.alignment_consensus = \
             self._alignment_summary(self.alignment)
     # cleanup temp files
     if clean:
         self._clean([aln, fasta])
예제 #3
0
 def run_alignment(self, clean=True, consensus=True):
     # dialign requires ENV variable be set for dialign_dir
     daln = which("dialign2-2")
     daln = os.path.join(os.path.split(daln)[0], 'dialign2_dir')
     os.environ["DIALIGN2_DIR"] = "/Users/bcf/Bin/dialign2_dir/"
     # create results file
     fd, aln = tempfile.mkstemp(suffix='.dialign')
     os.close(fd)
     # dialign makes an extra file for fasta output
     fasta = "{}.{}".format(aln, 'fa')
     # run MUSCLE on the temp file
     cmd = ["dialign2-2", "-fa", "-fn", aln, "-n", self.input]
     # just pass all ENV params
     proc = subprocess.Popen(cmd,
                             stderr=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             env=os.environ)
     stdout, stderr = proc.communicate()
     self.alignment = AlignIO.read(open(fasta, 'rU'), "fasta", \
             alphabet=Gapped(IUPAC.unambiguous_dna, "-"))
     # build a dumb consensus
     if consensus:
         self.alignment_summary, self.alignment_consensus = \
             self._alignment_summary(self.alignment)
     # cleanup temp files
     if clean:
         self._clean([aln, fasta])
예제 #4
0
파일: muscle.py 프로젝트: crinfante/phyluce
 def run_alignment(self, clean=True):
     """ muscle """
     # dialign requires ENV variable be set for dialign_dir
     muscle = which("muscle")
     # create results file
     fd, aln = tempfile.mkstemp(suffix='.muscle')
     os.close(fd)
     # run MUSCLE on the temp file
     cmd = [muscle, "-in", self.input, "-out", aln]
     proc = subprocess.Popen(cmd,
                             stderr=subprocess.PIPE,
                             stdout=subprocess.PIPE)
     stdout, stderr = proc.communicate()
     self.alignment = AlignIO.read(open(aln, 'rU'), \
             "fasta", alphabet=Gapped(IUPAC.unambiguous_dna, "-"))
     # cleanup temp files
     if clean:
         self._clean(aln)
예제 #5
0
파일: muscle.py 프로젝트: GrahamDB/phyluce
 def run_alignment(self, clean=True):
     """ muscle """
     # dialign requires ENV variable be set for dialign_dir
     muscle = which("muscle")
     # create results file
     fd, aln = tempfile.mkstemp(suffix='.muscle')
     os.close(fd)
     # run MUSCLE on the temp file
     cmd = [muscle, "-in", self.input, "-out", aln]
     proc = subprocess.Popen(cmd,
             stderr=subprocess.PIPE,
             stdout=subprocess.PIPE
         )
     stdout, stderr = proc.communicate()
     self.alignment = AlignIO.read(open(aln, 'rU'), \
             "fasta", alphabet=Gapped(IUPAC.unambiguous_dna, "-"))
     # cleanup temp files
     if clean:
         self._clean(aln)
예제 #6
0
파일: mafft.py 프로젝트: jonchang/phyluce
 def run_alignment(self, clean=True):
     mafft = which("mafft")
     # create results file
     fd, aln = tempfile.mkstemp(suffix='.mafft')
     os.close(fd)
     aln_stdout = open(aln, 'w')
     # run MAFFT on the temp file
     cmd = [mafft, "--adjustdirection", "--maxiterate", "1000", self.input]
     # just pass all ENV params
     proc = subprocess.Popen(cmd,
             stderr=subprocess.PIPE,
             stdout=aln_stdout
         )
     stderr = proc.communicate()
     aln_stdout.close()
     self.alignment = AlignIO.read(open(aln, 'rU'), "fasta", \
             alphabet=Gapped(IUPAC.unambiguous_dna, "-"))
     if clean:
         self._clean(aln)