allpy
changeset 137:0b366ce3257f
block, project: gap charecter can be changed, when save to fasta
| author | boris <bnagaev@gmail.com> |
|---|---|
| date | Sun, 24 Oct 2010 17:06:15 +0400 |
| parents | 6f886484b055 |
| children | 32b9f4fadd35 |
| files | geometrical_core/geometrical_core.py lib/block.py lib/project.py |
| diffstat | 3 files changed, 12 insertions(+), 8 deletions(-) [+] |
line diff
1.1 --- a/geometrical_core/geometrical_core.py Sun Oct 24 16:58:06 2010 +0400 1.2 +++ b/geometrical_core/geometrical_core.py Sun Oct 24 17:06:15 2010 +0400 1.3 @@ -121,3 +121,7 @@ 1.4 print 'Error: provide both pdb and spt file or none of them' 1.5 exit() 1.6 1.7 + 1.8 + 1.9 + 1.10 +
2.1 --- a/lib/block.py Sun Oct 24 16:58:06 2010 +0400 2.2 +++ b/lib/block.py Sun Oct 24 17:06:15 2010 +0400 2.3 @@ -40,7 +40,7 @@ 2.4 self.sequences = sequences 2.5 self.positions = positions 2.6 2.7 - def save_fasta(self, out_file, long_line=60): 2.8 + def save_fasta(self, out_file, long_line=60, gap='-'): 2.9 """ 2.10 Saves alignment to given file in fasta-format 2.11 Splits long lines to substrings of length=long_line 2.12 @@ -112,21 +112,21 @@ 2.13 break 2.14 return GCs 2.15 2.16 - def xstring(self, x='X'): 2.17 + def xstring(self, x='X', gap='-'): 2.18 """ 2.19 - Returns string consisting of '-' and chars x at self.positions 2.20 + Returns string consisting of gap chars and chars x at self.positions 2.21 Length of returning string = length of project 2.22 """ 2.23 monomers = [False] * len(self.project) 2.24 for i in self.positions: 2.25 monomers[i] = True 2.26 - return ''.join([x if m else '-' for m in monomers]) 2.27 + return ''.join([x if m else gap for m in monomers]) 2.28 2.29 - def save_xstring(self, out_file, name, description='', x='X'): 2.30 + def save_xstring(self, out_file, name, description='', x='X', gap='-'): 2.31 """ 2.32 Save xstring and name in fasta format 2.33 """ 2.34 out_file.write(">%(name)s %(description)s \n" % \ 2.35 {'name':name, 'description':description}) 2.36 2.37 - out_file.write(">%(xstring)s \n" % {'xstring':self.xstring()}) 2.38 + out_file.write(">%(xstring)s \n" % {'xstring':self.xstring(x=x, gap=gap)})
3.1 --- a/lib/project.py Sun Oct 24 16:58:06 2010 +0400 3.2 +++ b/lib/project.py Sun Oct 24 17:06:15 2010 +0400 3.3 @@ -153,13 +153,13 @@ 3.4 project.alignment[sequence] = sequence.monomers + [None] * gaps_count 3.5 return project 3.6 3.7 - def save_fasta(self, out_file, long_line=60): 3.8 + def save_fasta(self, out_file, long_line=60, gap='-'): 3.9 """ 3.10 Saves alignment to given file 3.11 Splits long lines to substrings of length=long_line 3.12 To prevent this, set long_line=None 3.13 """ 3.14 - Block(self).save_fasta(out_file, long_line) 3.15 + Block(self).save_fasta(out_file, long_line=long_line, gap=gap) 3.16 3.17 def muscle_align(self): 3.18 """
