本文整理匯總了Python中Bio.Alphabet.IUPAC.protein方法的典型用法代碼示例。如果您正苦於以下問題:Python IUPAC.protein方法的具體用法?Python IUPAC.protein怎麽用?Python IUPAC.protein使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bio.Alphabet.IUPAC
的用法示例。
在下文中一共展示了IUPAC.protein方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: transeq
# 需要導入模塊: from Bio.Alphabet import IUPAC [as 別名]
# 或者: from Bio.Alphabet.IUPAC import protein [as 別名]
def transeq(data):
dummy = int(data[1])
record = data[0]
if dummy == 0:
prot = (translate_frameshifted(record.seq[0:]))
prot_rec = (SeqRecord(Seq(prot, IUPAC.protein), id=record.id + "_strand0plus"))
if dummy == 1:
prot = (translate_frameshifted(record.seq[1:])) # second frame
prot_rec = (SeqRecord(Seq(prot, IUPAC.protein), id=record.id + "_strand1plus"))
if dummy == 2:
prot = (translate_frameshifted(record.seq[2:])) # third frame
prot_rec =(SeqRecord(Seq(prot, IUPAC.protein), id=record.id + "_strand2plus"))
if dummy == 3:
prot = (translate_frameshifted(reverse_complement(record.seq))) # negative first frame
prot_rec = (SeqRecord(Seq(prot, IUPAC.protein), id=record.id + "_strand0minus"))
if dummy == 4:
prot = (translate_frameshifted(reverse_complement(record.seq[:len(record.seq) - 1]))) # negative second frame
prot_rec =(SeqRecord(Seq(prot, IUPAC.protein), id=record.id + "_strand1minus"))
if dummy == 5:
prot = (translate_frameshifted(reverse_complement(record.seq[:len(record.seq) - 2]))) # negative third frame
prot_rec = (SeqRecord(Seq(prot, IUPAC.protein), id=record.id + "_strand2minus"))
return(prot_rec)
示例2: validate_folder_with_sequence_files
# 需要導入模塊: from Bio.Alphabet import IUPAC [as 別名]
# 或者: from Bio.Alphabet.IUPAC import protein [as 別名]
def validate_folder_with_sequence_files(
self, directory, file_format, sequence_type, ambiguous, file_extension, key=None, silent=False):
"""
Validate a file to be correctly formatted
@attention: Currently only phred quality for fastq files
@param directory: Path to directory with files containing sequences
@type directory: str | unicode
@param file_format: Format of the file at the file_path provided. Valid: 'fasta', 'fastq'
@type file_format: str | unicode
@param sequence_type: Are the sequences DNA or RNA? Valid: 'rna', 'dna', 'protein'
@type sequence_type: str | unicode
@param ambiguous: True or False, DNA example for strict 'GATC', ambiguous example 'GATCRYWSMKHBVDN'
@type ambiguous: bool
@param file_extension: file extension to be filtered for. Example: '.fasta' '.fq'
@type file_extension: basestring | None
@param key: If True, no error message will be made
@type key: basestring | None
@param silent: If True, no error message will be made
@type silent: bool
@return: True if the file is correctly formatted
@rtype: bool
"""
list_of_file_paths = self.get_files_in_directory(directory, file_extension)
result = True
for file_path in list_of_file_paths:
if not self.validate_sequence_file(file_path, file_format, sequence_type, ambiguous, key, silent):
result = False
return result
示例3: seq_record_example
# 需要導入模塊: from Bio.Alphabet import IUPAC [as 別名]
# 或者: from Bio.Alphabet.IUPAC import protein [as 別名]
def seq_record_example():
"""Dummy SeqRecord to load"""
return SeqRecord(Seq("MKQHKAMIVALIVICITAVVAALVTRKDLCEVHIRTGQTEVAVF",
IUPAC.protein),
id="YP_025292.1", name="HokC",
description="toxic membrane protein, small",
annotations={'hello':'world'})
示例4: validate_sequence_file
# 需要導入模塊: from Bio.Alphabet import IUPAC [as 別名]
# 或者: from Bio.Alphabet.IUPAC import protein [as 別名]
def validate_sequence_file(self, file_path, file_format, sequence_type, ambiguous, key=None, silent=False):
"""
Validate a file to be correctly formatted
@attention: Currently only phred quality for fastq files
@param file_path: Path to file containing sequences
@type file_path: str | unicode
@param file_format: Format of the file at the file_path provided. Valid: 'fasta', 'fastq'
@type file_format: str | unicode
@param sequence_type: Are the sequences DNA or RNA? Valid: 'rna', 'dna', 'protein'
@type sequence_type: str | unicode
@param ambiguous: True or False, DNA example for strict 'GATC', ambiguous example 'GATCRYWSMKHBVDN'
@type ambiguous: bool
@param key: If True, no error message will be made
@type key: basestring | None
@param silent: If True, no error message will be made
@type silent: bool
@return: True if the file is correctly formatted
@rtype: bool
"""
assert self.validate_file(file_path)
assert isinstance(file_format, basestring)
file_format = file_format.lower()
assert file_format in self._formats
assert isinstance(sequence_type, basestring)
sequence_type = sequence_type.lower()
assert sequence_type in self._alphabets
prefix = ""
if key:
prefix = "'{}' ".format(key)
if ambiguous:
alphabet = self._alphabets[sequence_type][1]
else:
alphabet = self._alphabets[sequence_type][0]
set_of_seq_id = set()
with open(file_path) as file_handle:
if not self._validate_file_start(file_handle, file_format):
if not silent:
self._logger.error("{}Invalid beginning of file '{}'.".format(prefix, os.path.basename(file_path)))
return False
sequence_count = 0
try:
for seq_record in SeqIO.parse(file_handle, file_format, alphabet=alphabet):
sequence_count += 1
if not self._validate_sequence_record(seq_record, set_of_seq_id, file_format, key=None, silent=False):
if not silent:
self._logger.error("{}{}. sequence '{}' is invalid.".format(prefix, sequence_count, seq_record.id))
return False
except Exception as e:
if not silent:
self._logger.error("{}Corrupt sequence in file '{}'.\nException: {}".format(
prefix, os.path.basename(file_path), e.message))
return False
return True