예제 #1
0
    def out():
        filename1 = e1.get()
        filename2 = e2.get()
        outfile = e3.get()

        needle_cline = WaterCommandline()
        needle_cline.asequence = filename1
        needle_cline.bsequence = filename2
        needle_cline.gapopen = int(gapopen)
        needle_cline.gapextend = int(gapextend)
        needle_cline.outfile = "needle.txt"
        print(needle_cline)
        print(needle_cline.outfile)
        stdout, stderr = needle_cline()
        print(stdout + stderr)
        align = AlignIO.read("needle.txt", "emboss")
        file = open("needle.txt", "r")
        # print(file.read())
        view = ("\n\n%s" % file.read())
        root = Tk()
        S = Scrollbar(root)
        T = Text(root, height=4, width=500)
        S.pack(side=RIGHT, fill=Y)
        T.pack(side=LEFT, fill=Y)
        S.config(command=T.yview)
        T.config(yscrollcommand=S.set)
        T.insert(END, view)

        with open(outfile, "w") as f:
            f.write(view)
예제 #2
0
 def test_water_file(self):
     """water with the asis trick, output to a file."""
     #Setup, try a mixture of keyword arguments and later additions:
     cline = WaterCommandline(cmd=exes["water"],
                              gapopen="10",
                              gapextend="0.5")
     #Try using both human readable names, and the literal ones:
     cline.set_parameter("asequence", "asis:ACCCGGGCGCGGT")
     cline.set_parameter("-bsequence", "asis:ACCCGAGCGCGGT")
     #Try using a property set here:
     cline.outfile = "Emboss/temp with space.water"
     self.assertEqual(str(eval(repr(cline))), str(cline))
     #Run the tool,
     result, out, err = generic_run(cline)
     #Check it worked,
     errors = err.read().strip()
     self.assert_(errors.startswith("Smith-Waterman local alignment"),
                  errors)
     self.assertEqual(out.read().strip(), "")
     if result.return_code != 0: print >> sys.stderr, "\n%s" % cline
     self.assertEqual(result.return_code, 0)
     filename = result.get_result("outfile")
     self.assertEqual(filename, "Emboss/temp with space.water")
     assert os.path.isfile(filename)
     #Check we can parse the output...
     align = AlignIO.read(open(filename), "emboss")
     self.assertEqual(len(align), 2)
     self.assertEqual(str(align[0].seq), "ACCCGGGCGCGGT")
     self.assertEqual(str(align[1].seq), "ACCCGAGCGCGGT")
     #Clean up,
     os.remove(filename)
예제 #3
0
 def test_water_file(self):
     """water with the asis trick, output to a file."""
     #Setup, try a mixture of keyword arguments and later additions:
     cline = WaterCommandline(cmd=exes["water"],
                              gapopen="10", gapextend="0.5")
     #Try using both human readable names, and the literal ones:
     cline.set_parameter("asequence", "asis:ACCCGGGCGCGGT")
     cline.set_parameter("-bsequence", "asis:ACCCGAGCGCGGT")
     #Try using a property set here:
     cline.outfile = "Emboss/temp with space.water"
     self.assertEqual(str(eval(repr(cline))), str(cline))
     #Run the tool,
     result, out, err = generic_run(cline)
     #Check it worked,
     errors = err.read().strip()
     self.assert_(errors.startswith("Smith-Waterman local alignment"), errors)
     self.assertEqual(out.read().strip(), "")
     if result.return_code != 0 : print >> sys.stderr, "\n%s"%cline
     self.assertEqual(result.return_code, 0)
     filename = result.get_result("outfile")
     self.assertEqual(filename, "Emboss/temp with space.water")
     assert os.path.isfile(filename)
     #Check we can parse the output...
     align = AlignIO.read(open(filename),"emboss")
     self.assertEqual(len(align), 2)
     self.assertEqual(str(align[0].seq), "ACCCGGGCGCGGT")
     self.assertEqual(str(align[1].seq), "ACCCGAGCGCGGT")
     #Clean up,
     os.remove(filename)            
예제 #4
0
파일: EMBOSSW23.py 프로젝트: fxb22/BioGUI
    def GetExec(self, optList, frame):
        # Respond to the "embossn" type command.
        self.frame = frame
        plugin_exe = r"C:/mEMBOSS/water.exe"
        self.outfile = r"C:\Users\francis\Documents\Monguis\BioGui\plugins\water.txt"
        self.outtype = "fasta"
        cline = WaterCommandline(plugin_exe, asequence=str(self.frame.paramBoxes[1].GetValue()), bsequence=str(self.frame.paramBoxes[3].GetValue()))
        cline.outfile = self.outfile
        cline.gapopen = self.param[7].GetValue()
        cline.gapextend = self.param[9].GetValue()
        if self.param[10].GetValue():
            cline.similarity = True
        else:
            cline.similarity = False

        if self.frame.abet=="AA":
            cline.snucleotide = True
            cline.sprotein = False
        elif self.frame.abet=="DNA" or self.frame.abet=="RNA":
            cline.snucleotide = True
            cline.sprotein = False
        if self.frame.options:
            t = self.boxList[3].GetValue()
            if t != '':
                cline.datafile = str(t)   
        return str(cline)
예제 #5
0
파일: EMBOSSW23.py 프로젝트: cwt1/BioGUI
    def GetExec(self, optList, frame):
        # Respond to the "embossn" type command.
        self.frame = frame
        plugin_exe = r"C:/mEMBOSS/water.exe"
        self.outfile = r"C:\Users\francis\Documents\Monguis\BioGui\plugins\water.txt"
        self.outtype = "fasta"
        cline = WaterCommandline(
            plugin_exe,
            asequence=str(self.frame.paramBoxes[1].GetValue()),
            bsequence=str(self.frame.paramBoxes[3].GetValue()))
        cline.outfile = self.outfile
        cline.gapopen = self.param[7].GetValue()
        cline.gapextend = self.param[9].GetValue()
        if self.param[10].GetValue():
            cline.similarity = True
        else:
            cline.similarity = False

        if self.frame.abet == "AA":
            cline.snucleotide = True
            cline.sprotein = False
        elif self.frame.abet == "DNA" or self.frame.abet == "RNA":
            cline.snucleotide = True
            cline.sprotein = False
        if self.frame.options:
            t = self.boxList[3].GetValue()
            if t != '':
                cline.datafile = str(t)
        return str(cline)
예제 #6
0
def waterAlign(seq1, seq2, gapopen, gapextend):
    water = WaterCommandline()
    water.asequence = seq1
    water.bsequence = seq2
    water.gapopen = gapopen
    water.gapextend = gapextend
    water.outfile = "needle.txt"

    stdout, stderr = water()
    print(stdout)
def doWater(contig, seq):
    with open("contig.faa", "w") as stuff1:
        stuff1.write(">contig\n")
        stuff1.write(contig)
    with open("seq.faa", "w") as stuff2:
        stuff2.write(">seq\n")
        stuff2.write(str(seq))
    water_cline = WaterCommandline()
    water_cline.asequence="contig.faa"
    water_cline.bsequence="seq.faa"
    water_cline.gapopen=10
    water_cline.gapextend=0.5
    water_cline.outfile="water.txt"
    stdout, stderr = water_cline()
    print(stdout + stderr)
    values = getStartEnd()
    return values
예제 #8
0
def emboss_local_pairwise_alignment(query_dir, seq_type):
    if seq_type == 'fg':
        print '\n   ...pairwise comparison of functional gene sequences...\n' 
    elif seq_type == 'ssu':
        print '\n   ...pairwise comparison of SSU rRNA sequences...\n'
    water_cline = WaterCommandline()
    water_cline.gapopen=10
    water_cline.gapextend=0.5
    query_list = [query for query in sorted(glob.glob(query_dir+"/*.fa"))]
    for i, a_seq in enumerate(query_list): 
        water_cline.asequence=str(a_seq)
        for j, b_seq in enumerate(query_list[i:]):
            water_cline.bsequence=str(b_seq)
            align_out = query_dir+"/pairwise_"+str(i+1)+"_"+str(i+j+1)+".aln"
            water_cline.outfile=str(align_out)
            water_cline()
    print 'Done\n'
    return query_dir+"/*.aln"
예제 #9
0
 def test_water_file(self):
     """Run water with the asis trick, output to a file."""
     # Setup, try a mixture of keyword arguments and later additions:
     cline = WaterCommandline(cmd=exes["water"], gapopen="10", gapextend="0.5")
     # Try using both human readable names, and the literal ones:
     cline.set_parameter("asequence", "asis:ACCCGGGCGCGGT")
     cline.set_parameter("-bsequence", "asis:ACCCGAGCGCGGT")
     # Try using a property set here:
     cline.outfile = "Emboss/temp with space.water"
     self.assertEqual(str(eval(repr(cline))), str(cline))
     # Run the tool,
     self.run_water(cline)
     # Check we can parse the output...
     align = AlignIO.read(cline.outfile, "emboss")
     self.assertEqual(len(align), 2)
     self.assertEqual(align[0].seq, "ACCCGGGCGCGGT")
     self.assertEqual(align[1].seq, "ACCCGAGCGCGGT")
     # Clean up,
     os.remove(cline.outfile)
예제 #10
0
 def test_water_file(self):
     """water with the asis trick, output to a file."""
     # Setup, try a mixture of keyword arguments and later additions:
     cline = WaterCommandline(cmd=exes["water"], gapopen="10", gapextend="0.5")
     # Try using both human readable names, and the literal ones:
     cline.set_parameter("asequence", "asis:ACCCGGGCGCGGT")
     cline.set_parameter("-bsequence", "asis:ACCCGAGCGCGGT")
     # Try using a property set here:
     cline.outfile = "Emboss/temp with space.water"
     self.assertEqual(str(eval(repr(cline))), str(cline))
     # Run the tool,
     self.run_water(cline)
     # Check we can parse the output...
     align = AlignIO.read(open(cline.outfile), "emboss")
     self.assertEqual(len(align), 2)
     self.assertEqual(str(align[0].seq), "ACCCGGGCGCGGT")
     self.assertEqual(str(align[1].seq), "ACCCGAGCGCGGT")
     # Clean up,
     os.remove(cline.outfile)
예제 #11
0
# http://rosalind.info/problems/swat/

from Bio.Emboss.Applications import WaterCommandline
from Bio import ExPASy, SeqIO


if __name__ == "__main__":
    ids = open('rosalind_swat.txt').read().split(' ')

    for i in ids:
        handle = ExPASy.get_sprot_raw(i)
        r = SeqIO.read(handle, "swiss")
        handle.close()
        
        with open(i, 'w') as f:
            SeqIO.write(r, f, 'fasta')

    water_cline = WaterCommandline()
    water_cline.asequence = ids[0]
    water_cline.bsequence = ids[1]
    water_cline.outfile = "rosalind_swat_output.txt"
    water_cline.gapopen = 10
    water_cline.gapextend = 1
    water_cline()

    for line in  open('rosalind_swat_output.txt').readlines():
        if 'Score:' in line:
            print(int(float(line[:-1].split(':')[-1].strip())))
예제 #12
0
파일: swat.py 프로젝트: luizirber/rosalind
from Bio import ExPASy
from Bio import SeqIO


if __name__ == "__main__":
    with open(os.path.join('data', 'rosalind_swat.txt')) as dataset:
        ids = dataset.read().split()

    for i in ids:
        handle = ExPASy.get_sprot_raw(i)
        r = SeqIO.read(handle, "swiss")
        handle.close()
        with open(i, 'w') as f:
            SeqIO.write(r, f, 'fasta')

    water_cline = WaterCommandline()
    water_cline.asequence = ids[0]
    water_cline.bsequence = ids[1]
    water_cline.outfile = "water.txt"
    water_cline.gapopen = 10
    water_cline.gapextend = 1

    water_cline()

    with open('water.txt') as f:
        output = f.readlines()

    for line in output:
        if 'Score:' in line:
            print(int(float(line[:-1].split(':')[-1].strip())))
예제 #13
0
# http://rosalind.info/problems/swat/

from Bio.Emboss.Applications import WaterCommandline
from Bio import ExPASy, SeqIO

if __name__ == "__main__":
    ids = open('rosalind_swat.txt').read().split(' ')

    for i in ids:
        handle = ExPASy.get_sprot_raw(i)
        r = SeqIO.read(handle, "swiss")
        handle.close()

        with open(i, 'w') as f:
            SeqIO.write(r, f, 'fasta')

    water_cline = WaterCommandline()
    water_cline.asequence = ids[0]
    water_cline.bsequence = ids[1]
    water_cline.outfile = "rosalind_swat_output.txt"
    water_cline.gapopen = 10
    water_cline.gapextend = 1
    water_cline()

    for line in open('rosalind_swat_output.txt').readlines():
        if 'Score:' in line:
            print(int(float(line[:-1].split(':')[-1].strip())))
예제 #14
0
from Bio.Emboss.Applications import WaterCommandline
from Bio import ExPASy
from Bio import SeqIO

if __name__ == "__main__":
    with open(os.path.join('data', 'rosalind_swat.txt')) as dataset:
        ids = dataset.read().split()

    for i in ids:
        handle = ExPASy.get_sprot_raw(i)
        r = SeqIO.read(handle, "swiss")
        handle.close()
        with open(i, 'w') as f:
            SeqIO.write(r, f, 'fasta')

    water_cline = WaterCommandline()
    water_cline.asequence = ids[0]
    water_cline.bsequence = ids[1]
    water_cline.outfile = "water.txt"
    water_cline.gapopen = 10
    water_cline.gapextend = 1

    water_cline()

    with open('water.txt') as f:
        output = f.readlines()

    for line in output:
        if 'Score:' in line:
            print(int(float(line[:-1].split(':')[-1].strip())))
예제 #15
0
"""
This is the first example of Python script.
"""
a = 10  # variable a
b = 33  # variable b
c = a / b  # variable c holds the ratio

# Let's print the result to screen.
print("a:", a, " b:", b, " a/b=", c)

from Bio.Seq import Seq

a = Seq("ATATATACG")

a.alphabet
a.sequence()

from Bio.Emboss.Applications import WaterCommandline
cline = WaterCommandline(gapopen=10, gapextend=0.5)
cline.asequence = "asis:ACCCGGGCGCGGT"
cline.bsequence = "asis:ACCCGAGCGCGGT"
cline.outfile = "temp_water.txt"
print(cline)