本文整理汇总了Python中Bio.Emboss.Applications.WaterCommandline类的典型用法代码示例。如果您正苦于以下问题:Python WaterCommandline类的具体用法?Python WaterCommandline怎么用?Python WaterCommandline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WaterCommandline类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_water_file
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)
示例2: generate_water_cmd
def generate_water_cmd(macierz, pliki_fasta_rodzina):
"""
Generuje polecenia wywolania programu water EMBOSS dla wszystkich sekwencji podanych jako nazwy plikow je zawierajacych
:param macierz: lokalizacja/nazwa pliku z macierza substytucji PAM/BLOSUM
:param pliki_fasta_fodzina: lista lokalizacji/nazw plikow z sekwencjami bialkowymi fasta nalezacymi do danej rodziny
:return: polecenie wywolania programu water
"""
records = []
for file in pliki_fasta_rodzina:
handle = open(file, "rU")
records.extend(list(SeqIO.parse(handle, "fasta")))
handle.close()
from Bio.Emboss.Applications import WaterCommandline
all_water_cmd = []
for i in range(len(records)):
for j in range(len(records)):
if i < j:
water_cmd = WaterCommandline(gapopen=100, gapextend=10)#maksymalne wartosci aby uzyskac uliniowienia bezspacjowe
water_cmd.asequence = "asis:" + str(records[i].seq)
water_cmd.bsequence = "asis:" + str(records[j].seq)
water_cmd.stdout = True
water_cmd.sprotein=True
water_cmd.datafile=macierz
all_water_cmd.append(str(water_cmd))
return all_water_cmd
示例3: doWater
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
示例4: emboss_local_pairwise_alignment
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"
示例5: test_water_file
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)
示例6: test_water_file4
def test_water_file4(self):
"""water with the asis trick and SwissProt file, output to a file."""
# Setup,
query = "DVCTGKALCDPVTQNIKTYPVKIENLRVMI"
out_file = "Emboss/temp_test4.water"
in_file = "SwissProt/sp004"
self.assertTrue(os.path.isfile(in_file))
if os.path.isfile(out_file):
os.remove(out_file)
cline = WaterCommandline(cmd=exes["water"])
cline.set_parameter("-asequence", "asis:%s" % query)
cline.set_parameter("-bsequence", in_file)
# EMBOSS should work this out, but let's be explicit:
cline.set_parameter("-sprotein", True)
# TODO - Tell water this is a SwissProt file!
cline.set_parameter("-gapopen", "20")
cline.set_parameter("-gapextend", "5")
cline.set_parameter("-outfile", out_file)
self.assertEqual(str(eval(repr(cline))), str(cline))
# Run the tool,
self.run_water(cline)
# Check we can parse the output and it is sensible...
self.pairwise_alignment_check(query,
SeqIO.parse(in_file, "swiss"),
AlignIO.parse(out_file, "emboss"),
local=True)
# Clean up,
os.remove(out_file)
示例7: test_water_file3
def test_water_file3(self):
"""water with the asis trick and GenBank file, output to a file."""
# Setup,
query = "TGTTGTAATGTTTTAATGTTTCTTCTCCCTTTAGATGTACTACGTTTGGA"
out_file = "Emboss/temp_test3.water"
in_file = "GenBank/cor6_6.gb"
self.assertTrue(os.path.isfile(in_file))
if os.path.isfile(out_file):
os.remove(out_file)
cline = WaterCommandline(cmd=exes["water"])
cline.set_parameter("asequence", "asis:%s" % query)
cline.set_parameter("bsequence", in_file)
# TODO - Tell water this is a GenBank file!
cline.set_parameter("gapopen", "1")
cline.set_parameter("gapextend", "0.5")
cline.set_parameter("outfile", out_file)
self.assertEqual(str(eval(repr(cline))), str(cline))
# Run the tool,
self.run_water(cline)
# Check we can parse the output and it is sensible...
self.pairwise_alignment_check(query,
SeqIO.parse(in_file, "genbank"),
AlignIO.parse(out_file, "emboss"),
local=True)
# Clean up,
os.remove(out_file)
示例8: test_water_file2
def test_water_file2(self):
"""water with the asis trick and nucleotide FASTA file, output to a file."""
# Setup,
query = "ACACACTCACACACACTTGGTCAGAGATGCTGTGCTTCTTGGAAGCAAGGNCTCAAAGGCAAGGTGCACGCAGAGGGACGTTTGAGTCTGGGATGAAGCATGTNCGTATTATTTATATGATGGAATTTCACGTTTTTATG"
out_file = "Emboss/temp_test2.water"
in_file = "Fasta/f002"
self.assertTrue(os.path.isfile(in_file))
if os.path.isfile(out_file):
os.remove(out_file)
cline = WaterCommandline(cmd=exes["water"])
cline.set_parameter("-asequence", "asis:%s" % query)
cline.set_parameter("-bsequence", in_file)
cline.set_parameter("-gapopen", "10")
cline.set_parameter("-gapextend", "0.5")
cline.set_parameter("-outfile", out_file)
self.assertEqual(str(eval(repr(cline))), str(cline))
# Run the tool,
self.run_water(cline)
# Check we can parse the output and it is sensible...
self.pairwise_alignment_check(query,
SeqIO.parse(in_file, "fasta"),
AlignIO.parse(out_file, "emboss"),
local=True)
# Clean up,
os.remove(out_file)
示例9: open
# 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())))
示例10: open
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())))
示例11: GetExec
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)
示例12: test_water_file4
def test_water_file4(self):
"""water with the asis trick and SwissProt file, output to a file."""
#Setup,
query = "DVCTGKALCDPVTQNIKTYPVKIENLRVMI"
out_file = "Emboss/temp_test4.water"
in_file = "SwissProt/sp004"
self.assert_(os.path.isfile(in_file))
if os.path.isfile(out_file) :
os.remove(out_file)
cline = WaterCommandline(cmd=exes["water"])
cline.set_parameter("-asequence", "asis:%s" % query)
cline.set_parameter("-bsequence", in_file)
#EMBOSS should work this out, but let's be explicit:
cline.set_parameter("-sprotein", True)
#TODO - Tell water this is a SwissProt file!
cline.set_parameter("-gapopen", "20")
cline.set_parameter("-gapextend", "5")
cline.set_parameter("-outfile", out_file)
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)
#Should be able to access this via any alias:
self.assertEqual(result.get_result("-outfile"), out_file)
assert os.path.isfile(out_file)
#Check we can parse the output and it is sensible...
self.pairwise_alignment_check(query,
SeqIO.parse(open(in_file),"swiss"),
AlignIO.parse(open(out_file),"emboss"),
local=True)
#Clean up,
os.remove(out_file)
示例13: test_water_file3
def test_water_file3(self):
"""water with the asis trick and GenBank file, output to a file."""
#Setup,
query = "TGTTGTAATGTTTTAATGTTTCTTCTCCCTTTAGATGTACTACGTTTGGA"
out_file = "Emboss/temp_test3.water"
in_file = "GenBank/cor6_6.gb"
self.assert_(os.path.isfile(in_file))
if os.path.isfile(out_file) :
os.remove(out_file)
cline = WaterCommandline(cmd=exes["water"])
cline.set_parameter("asequence", "asis:%s" % query)
cline.set_parameter("bsequence", in_file)
#TODO - Tell water this is a GenBank file!
cline.set_parameter("gapopen", "1")
cline.set_parameter("gapextend", "0.5")
cline.set_parameter("outfile", out_file)
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)
self.assertEqual(result.get_result("outfile"), out_file)
assert os.path.isfile(out_file)
#Check we can parse the output and it is sensible...
self.pairwise_alignment_check(query,
SeqIO.parse(open(in_file),"genbank"),
AlignIO.parse(open(out_file),"emboss"),
local=True)
#Clean up,
os.remove(out_file)
示例14: test_water_file2
def test_water_file2(self):
"""water with the asis trick and nucleotide FASTA file, output to a file."""
#Setup,
query = "ACACACTCACACACACTTGGTCAGAGATGCTGTGCTTCTTGGAAGCAAGGNCTCAAAGGCAAGGTGCACGCAGAGGGACGTTTGAGTCTGGGATGAAGCATGTNCGTATTATTTATATGATGGAATTTCACGTTTTTATG"
out_file = "Emboss/temp_test2.water"
in_file = "Fasta/f002"
self.assert_(os.path.isfile(in_file))
if os.path.isfile(out_file) :
os.remove(out_file)
cline = WaterCommandline(cmd=exes["water"])
cline.set_parameter("-asequence", "asis:%s" % query)
cline.set_parameter("-bsequence", in_file)
cline.set_parameter("-gapopen", "10")
cline.set_parameter("-gapextend", "0.5")
cline.set_parameter("-outfile", out_file)
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)
self.assertEqual(result.get_result("outfile"), out_file)
assert os.path.isfile(out_file)
#Check we can parse the output and it is sensible...
self.pairwise_alignment_check(query,
SeqIO.parse(open(in_file),"fasta"),
AlignIO.parse(open(out_file),"emboss"),
local=True)
#Clean up,
os.remove(out_file)