本文整理汇总了Python中Bio.Align.Generic.Alignment.get_column方法的典型用法代码示例。如果您正苦于以下问题:Python Alignment.get_column方法的具体用法?Python Alignment.get_column怎么用?Python Alignment.get_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.Align.Generic.Alignment
的用法示例。
在下文中一共展示了Alignment.get_column方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_column
# 需要导入模块: from Bio.Align.Generic import Alignment [as 别名]
# 或者: from Bio.Align.Generic.Alignment import get_column [as 别名]
def get_column(self, col):
"""Returns a string containing a given column (OBSOLETE).
This is a method provided for backwards compatibility with the old
Bio.Align.Generic.Alignment object. You are encouraged to use the
slice notation instead.
"""
return _Alignment.get_column(self, col)
示例2: get_column
# 需要导入模块: from Bio.Align.Generic import Alignment [as 别名]
# 或者: from Bio.Align.Generic.Alignment import get_column [as 别名]
def get_column(self, col):
"""Returns a string containing a given column (DEPRECATED).
This is a method provided for backwards compatibility with the old
Bio.Align.Generic.Alignment object. Please use the slice notation
instead, since get_column is likely to be removed in a future release
of Biopython..
"""
import warnings
import Bio
warnings.warn("This method is deprecated and is provided for backwards compatibility with the old Bio.Align.Generic.Alignment object. Please use the slice notation instead, as get_column is likely to be removed in a future release of Biopython.", Bio.BiopythonDeprecationWarning)
return _Alignment.get_column(self, col)
示例3: Alignment
# 需要导入模块: from Bio.Align.Generic import Alignment [as 别名]
# 或者: from Bio.Align.Generic.Alignment import get_column [as 别名]
#Basic tests on simple three string alignment
alignment = Alignment(Alphabet.generic_alphabet)
letters = "AbcDefGhiJklMnoPqrStuVwxYz"
alignment.add_sequence("mixed", letters)
alignment.add_sequence("lower", letters.lower())
alignment.add_sequence("upper", letters.upper())
assert alignment.get_alignment_length() == 26
assert len(alignment) == 3
assert alignment.get_seq_by_num(0).tostring() == letters
assert alignment.get_seq_by_num(1).tostring() == letters.lower()
assert alignment.get_seq_by_num(2).tostring() == letters.upper()
assert alignment[0].description == "mixed"
assert alignment[1].description == "lower"
assert alignment[2].description == "upper"
for (col, letter) in enumerate(letters):
assert alignment.get_column(col) == letter \
+ letter.lower() \
+ letter.upper()
#Check row extractions:
assert alignment[0].id == "mixed"
assert alignment[-1].id == "upper"
#Check sub-alignment extraction by row slicing:
assert isinstance(alignment[::-1], Alignment)
assert alignment[::-1][0].id == "upper"
assert alignment[::-1][2].id == "mixed"
del alignment
del letters
print "testing reading and writing clustal format..."
test_dir = os.path.join(os.getcwd(), 'Clustalw')
示例4: Align
# 需要导入模块: from Bio.Align.Generic import Alignment [as 别名]
# 或者: from Bio.Align.Generic.Alignment import get_column [as 别名]
class Align(object):
"""docstring for Align"""
def __init__(self, input):
self.input = input
self.alignment = None
self.trimmed_alignment = None
self.perfect_trimmed_alignment = None
def _clean(self, outtemp):
# cleanup temp file
os.remove(outtemp)
# cleanup input file
os.remove(self.input)
def _find_ends(self, forward=True):
"""determine the first (or last) position where all reads in an alignment
start/stop matching"""
if forward:
theRange = xrange(self.alignment.get_alignment_length())
else:
theRange = reversed(xrange(self.alignment.get_alignment_length()))
for col in theRange:
if '-' in self.alignment.get_column(col):
pass
else:
break
return col
def _base_checker(self, bases, sequence, loc):
"""ensure that any trimming that occurs does not start beyong the
end of the sequence being trimmed"""
# deal with the case where we just want to measure out from the
# middle of a particular sequence
if len(loc) == 1:
loc = (loc, loc)
if not bases > len(sequence.seq[:loc[0]]) and \
not bases > len(sequence.seq[loc[1]:]):
return True
def _record_formatter(self, temp):
"""return a string formatted as a biopython sequence record"""
temp_record = SeqRecord(temp)
temp_record.id = sequence.id
temp_record.name = sequence.name
temp_record.description = sequence.description
return temp_record
def _alignment_summary(self, alignment):
"""return summary data for an alignment object using the AlignInfo
class from BioPython"""
summary = AlignInfo.SummaryInfo(alignment)
consensus = summary.dumb_consensus()
return summary, consensus
def _read(self, format):
"""read an alignment from the CLI - largely for testing purposes"""
self.alignment = AlignIO.read(open(self.input,'rU'), format)
def get_probe_location(self):
'''Pull the probe sequence from an alignment object and determine its position
within the read'''
# probe at bottom => reverse order
for record in self.alignment[::-1]:
if record.id == 'probe':
start = re.search('^-*', str(record.seq))
end = re.search('-*$', str(record.seq))
# should be first record
break
# ooh, this seems so very backwards
self.ploc = (start.end(), end.start(),)
def run_alignment(self, clean = True, consensus = True):
"""Align, as originally written gets bogged down. Add communicate method
and move away from pipes for holding information (this has always been
problematic for me with multiprocessing). Move to tempfile-based
output."""
# create results file
fd, outtemp = tempfile.mkstemp(suffix='.align')
os.close(fd)
# run MUSCLE on the temp file
cline = MuscleCommandline(input=self.input, out=outtemp)
stdout, stderr = subprocess.Popen(str(cline),
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
shell=True).communicate(None)
self.alignment = AlignIO.read(open(outtemp,'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(outtemp)
def running_average(self, window_size, threshold):
# iterate across the columns of the alignment and determine presence
# or absence of base-identity in the column
differences = []
for column in xrange(self.alignment.get_alignment_length()):
column_values = self.alignment.get_column(column)
#.........这里部分代码省略.........
示例5: str
# 需要导入模块: from Bio.Align.Generic import Alignment [as 别名]
# 或者: from Bio.Align.Generic.Alignment import get_column [as 别名]
align=Alignment(Bio.Alphabet.Gapped(IUPAC.protein)) #instance of Alignment class
align.add_sequence('asp',seq1)
align.add_sequence('unk',seq2)
print align
#Alignment methods
#get_all_seqs: return all sequences in the alignment as a list of SeqRecord
for s in align.get_all_seqs(): #in align: (the same)
print '->',s.seq
#get_seq_by_num(n): return only the selected sequence by index
print str(align.get_seq_by_num(1)) #Seq object
print align[0] #SeqRecord object
print str(align[0].seq)
#get_alignment_length(): get length of alignment
print align.get_alignment_length()
#get_column(n): return a string with all the letters in the n column
print align.get_column(0)
print align.get_column(2)
#AlignInfo module: to extract info from alignment objects
from Bio.Align import AlignInfo
#print_info_content function
#SummaryInfo,PSSM classes
summary=AlignInfo.SummaryInfo(align)
print summary.information_content()
print summary.dumb_consensus()
print summary.gap_consensus()
print summary.get_column(2) #get column by index
print summary.alignment #complete description
#Bio.SeqIO: interface to input & output sequence file formats
#passed to your program as SeqRecord objects