当前位置: 首页>>代码示例>>Python>>正文


Python SeqFeature.SeqFeature方法代码示例

本文整理汇总了Python中Bio.SeqFeature.SeqFeature方法的典型用法代码示例。如果您正苦于以下问题:Python SeqFeature.SeqFeature方法的具体用法?Python SeqFeature.SeqFeature怎么用?Python SeqFeature.SeqFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bio.SeqFeature的用法示例。


在下文中一共展示了SeqFeature.SeqFeature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_point_feature

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def add_point_feature(self, resnum, feat_type=None, feat_id=None, qualifiers=None):
        """Add a feature to the features list describing a single residue.

        Args:
            resnum (int): Protein sequence residue number
            feat_type (str, optional): Optional description of the feature type (ie. 'catalytic residue')
            feat_id (str, optional): Optional ID of the feature type (ie. 'TM1')

        """
        if self.feature_file:
            raise ValueError('Feature file associated with sequence, please remove file association to append '
                             'additional features.')

        if not feat_type:
            feat_type = 'Manually added protein sequence single residue feature'
        newfeat = SeqFeature(location=FeatureLocation(ExactPosition(resnum-1), ExactPosition(resnum)),
                             type=feat_type,
                             id=feat_id,
                             qualifiers=qualifiers)

        self.features.append(newfeat) 
开发者ID:SBRG,项目名称:ssbio,代码行数:23,代码来源:seqprop.py

示例2: add_region_feature

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def add_region_feature(self, start_resnum, end_resnum, feat_type=None, feat_id=None, qualifiers=None):
        """Add a feature to the features list describing a region of the protein sequence.

        Args:
            start_resnum (int): Start residue number of the protein sequence feature
            end_resnum (int): End residue number of the protein sequence feature
            feat_type (str, optional): Optional description of the feature type (ie. 'binding domain')
            feat_id (str, optional): Optional ID of the feature type (ie. 'TM1')

        """
        if self.feature_file:
            raise ValueError('Feature file associated with sequence, please remove file association to append '
                             'additional features.')

        if not feat_type:
            feat_type = 'Manually added protein sequence region feature'
        newfeat = SeqFeature(location=FeatureLocation(start_resnum-1, end_resnum),
                             type=feat_type,
                             id=feat_id,
                             qualifiers=qualifiers)

        self.features.append(newfeat) 
开发者ID:SBRG,项目名称:ssbio,代码行数:24,代码来源:seqprop.py

示例3: get_residue_annotations

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def get_residue_annotations(self, start_resnum, end_resnum=None):
        """Retrieve letter annotations for a residue or a range of residues

        Args:
            start_resnum (int): Residue number
            end_resnum (int): Optional residue number, specify if a range is desired

        Returns:
            dict: Letter annotations for this residue or residues

        """
        if not end_resnum:
            end_resnum = start_resnum

        # Create a new SeqFeature
        f = SeqFeature(FeatureLocation(start_resnum - 1, end_resnum))

        # Get sequence properties
        return f.extract(self).letter_annotations 
开发者ID:SBRG,项目名称:ssbio,代码行数:21,代码来源:seqprop.py

示例4: test_translate_feature

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def test_translate_feature(self):
        '''
        Test translate_feature from a dictionary of given nucleotides to dictionary of translated amino acids
        '''
        # Seq -> Amino https://en.wikipedia.org/wiki/DNA_codon_table
        seq1 = Seq("TTTCTTATGGTCGTA") 
        seq2 = Seq("TCTTCAACTGCTACA")
        seq3 = Seq("CATAATGAATATAAT")
        aln = {'seq1': seq1,
               'seq2': seq2,
               'seq3': seq3}
        feature = SeqFeature(FeatureLocation(0, 15), type="domain")

        # expected results
        expected_translations = {'seq1': 'FLMVV',
                                 'seq2': 'SSTAT',
                                 'seq3': 'HNEYN'}

        assert translate.translate_feature(aln, feature) == expected_translations

    # TODO: test_vcf_feature, assign_aa_vcf, assign_aa_fasta
    # Unclear how to emulate inputs (TreeTime dict, tree) 
开发者ID:nextstrain,项目名称:augur,代码行数:24,代码来源:test_translate.py

示例5: create_faux_record_from_proteins

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def create_faux_record_from_proteins(proteins, id):
    from Bio.SeqRecord import SeqRecord
    from Bio.Seq import Seq
    from Bio.SeqFeature import SeqFeature, FeatureLocation
    record = SeqRecord(seq=Seq(''), id=id)
    start = 0
    end = 0
    max_protein_id_len = 45
    for protein in proteins:
        nucl_length = len(protein.seq) * 3
        end += nucl_length
        feature = SeqFeature(
            location=FeatureLocation(start, end, strand=1),
            type="CDS",
            qualifiers={
                'protein_id': [protein.id[:max_protein_id_len]],
                'translation': [str(protein.seq)]
            }
        )
        start += nucl_length
        record.features.append(feature)
    return record 
开发者ID:Merck,项目名称:deepbgc,代码行数:24,代码来源:util.py

示例6: fetch_source_feature

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def fetch_source_feature(self, gb_record):
        source_feature = None
        has_source = False
        for i in gb_record.features:
            if i.type == "source":
                source_feature = i
                has_source = True
                break
        if not has_source:
            ##加一个source feature
            my_start_pos = SeqFeature.ExactPosition(0)
            my_end_pos = SeqFeature.ExactPosition(len(gb_record.seq))
            my_feature_location = FeatureLocation(my_start_pos, my_end_pos)
            my_feature_type = "source"
            source_feature = SeqFeature.SeqFeature(my_feature_location, type=my_feature_type)
            gb_record.features.insert(0, source_feature)
        return source_feature 
开发者ID:dongzhang0725,项目名称:PhyloSuite,代码行数:19,代码来源:handleGB.py

示例7: drawFig

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def drawFig(self):
        gdd = GenomeDiagram.Diagram('linear figure')
        gdt_features = gdd.new_track(1, greytrack=False, scale=0, height=0.4)
        gds_features = gdt_features.new_set()
        for name, start, stop in self.list_name_start_stop:
            if "COX" in name.upper():
                color = "#81CEEA"
            elif "NAD" in name.upper():
                color = "#F9C997"
            elif "ATP" in name.upper():
                color = "#E97E8D"
            elif ("CYTB" in name.upper()) or ("COB" in name.upper()):
                color = "#E2E796"
            elif "RRN" in name.upper():
                color = "#94F2DB"
            # strand = -1 if name in ["nad1", "cytb", "nad4", "nad4L", "rrnL"] else 1
            feature = SeqFeature(FeatureLocation(int(start), int(stop)), strand=1)
            gds_features.add_feature(feature, name=name, label=True,
                                     label_size=self.dict_args["label_size"], label_angle=self.dict_args["Label_angle"],
                                     color=self.dict_args["Label_color"], label_position=self.dict_args["Label_position"],
                                     sigil="BIGARROW", arrowshaft_height=0.5,
                                     arrowhead_length=0.5)
        gdd.draw(format='linear', pagesize=(self.dict_args["fig_width"] * cm, self.dict_args["fig_height"] * cm), fragments=1,
                 start=0, end=int(stop))
        gdd.write(self.dict_args["exportPath"] + os.sep + "linear.pdf", "pdf") 
开发者ID:dongzhang0725,项目名称:PhyloSuite,代码行数:27,代码来源:Lg_Concatenate.py

示例8: store_promoters

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def store_promoters(promoters: Iterable[Promoter], record: Record) -> None:
    """Store information about promoter sequences to a SeqRecord"""
    for promoter in promoters:
        # remember to account for 0-indexed start location
        new_feature = SeqFeature(FeatureLocation(max(0, promoter.start - 1), promoter.end),
                                 type="promoter")
        new_feature.qualifiers = {
            "locus_tag": promoter.get_gene_names(),  # already a list with one or two elements
            "seq": [str(promoter.seq)],
        }

        if isinstance(promoter, CombinedPromoter):
            new_feature.qualifiers["note"] = ["bidirectional promoter"]

        secmet_version = Feature.from_biopython(new_feature)
        secmet_version.created_by_antismash = True

        record.add_feature(secmet_version) 
开发者ID:antismash,项目名称:antismash,代码行数:20,代码来源:__init__.py

示例9: from_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def from_biopython(cls: Type[T], bio_feature: SeqFeature, feature: T = None,
                       leftovers: Dict[str, List[str]] = None, record: Any = None) -> T:
        if leftovers is None:
            leftovers = Feature.make_qualifiers_copy(bio_feature)
        # grab mandatory qualifiers and create the class
        tool = leftovers.pop("aSTool")[0]
        protein_location = generate_protein_location_from_qualifiers(leftovers, record)
        # locus tag is special, antismash versions <= 5.0 didn't require it, but > 5.0 do
        locus_tag = leftovers.pop("locus_tag", ["(unknown)"])[0]
        feature = cls(bio_feature.location, tool, protein_location, locus_tag)

        # grab optional qualifiers
        feature.domain_subtype = leftovers.pop("domain_subtype", [""])[0] or None
        feature.specificity = leftovers.pop("specificity", [])

        # grab parent optional qualifiers
        super().from_biopython(bio_feature, feature=feature, leftovers=leftovers, record=record)

        return feature 
开发者ID:antismash,项目名称:antismash,代码行数:21,代码来源:antismash_domain.py

示例10: from_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def from_biopython(cls: Type[T], bio_feature: SeqFeature, feature: T = None,
                       leftovers: Optional[Dict] = None, record: Any = None) -> T:
        if leftovers is None:
            leftovers = Feature.make_qualifiers_copy(bio_feature)

        tool = leftovers.pop("aStool")[0]
        probability = None
        if "probability" in leftovers:
            probability = float(leftovers.pop("probability")[0])
        label = leftovers.pop("label", [""])[0]
        if not label:
            label = leftovers.pop("anchor", [""])[0]  # backwards compatibility
        if not feature:
            feature = cls(bio_feature.location, tool, probability, label)

        # remove the subregion_number, as it's not relevant
        leftovers.pop("subregion_number", "")

        # grab parent optional qualifiers
        super().from_biopython(bio_feature, feature=feature, leftovers=leftovers, record=record)
        return feature 
开发者ID:antismash,项目名称:antismash,代码行数:23,代码来源:subregion.py

示例11: to_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def to_biopython(self, qualifiers: Dict[str, List[str]] = None) -> SeqFeature:
        mine = OrderedDict()  # type: Dict[str, List[str]]
        # mandatory
        mine["translation"] = [self.translation]
        # optional
        for attr in ["gene", "transl_table", "locus_tag",
                     "protein_id", "product"]:
            val = getattr(self, attr)
            if val:
                mine[attr] = [str(val)]
        if self._gene_functions:
            mine["gene_functions"] = list(map(str, self._gene_functions))
            mine["gene_kind"] = [str(self.gene_function)]
        if self.sec_met:
            mine["sec_met_domain"] = list(map(str, self.sec_met))
        if self.nrps_pks:
            mine["NRPS_PKS"] = list(map(str, self.nrps_pks))
        # respect qualifiers given to us
        if qualifiers:
            mine.update(qualifiers)
        return super().to_biopython(mine) 
开发者ID:antismash,项目名称:antismash,代码行数:23,代码来源:cds_feature.py

示例12: from_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def from_biopython(cls: Type[T], bio_feature: SeqFeature, feature: T = None,
                       leftovers: Dict[str, List[str]] = None, record: Any = None) -> T:
        if leftovers is None:
            leftovers = Feature.make_qualifiers_copy(bio_feature)

        candidate_numbers = [int(num) for num in leftovers.pop("candidate_cluster_numbers", [])]
        subregion_numbers = [int(num) for num in leftovers.pop("subregion_numbers", [])]

        if not record:
            raise ValueError("record instance required for regenerating Region from biopython")

        all_candidates = record.get_candidate_clusters()
        all_subs = record.get_subregions()

        if candidate_numbers and max(candidate_numbers) > len(all_candidates):
            raise ValueError("record does not contain all expected candidate clusters")
        if subregion_numbers and max(subregion_numbers) > len(all_subs):
            raise ValueError("record does not contain all expected subregions")

        candidates = [all_candidates[num - 1] for num in candidate_numbers]
        subs = [all_subs[num - 1] for num in subregion_numbers]

        return cls(candidates, subs) 
开发者ID:antismash,项目名称:antismash,代码行数:25,代码来源:region.py

示例13: from_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def from_biopython(cls: Type[T], bio_feature: SeqFeature, feature: T = None,
                       leftovers: Dict[str, List[str]] = None, record: Any = None) -> T:
        if leftovers is None:
            leftovers = Feature.make_qualifiers_copy(bio_feature)
        if not feature:
            raise ValueError("Domain shouldn't be instantiated directly")
        else:
            assert isinstance(feature, Domain), type(feature)

        # clean up qualifiers that must have been used already
        leftovers.pop("protein_start", None)
        leftovers.pop("protein_end", None)

        # grab optional qualifiers
        feature.domain = leftovers.pop("aSDomain", [""])[0] or None
        for asf_label in leftovers.pop("ASF", []):
            feature.asf.add(asf_label)

        # grab parent optional qualifiers
        updated = super().from_biopython(bio_feature, feature=feature, leftovers=leftovers, record=record)
        assert updated is feature
        assert isinstance(updated, Domain)
        return updated 
开发者ID:antismash,项目名称:antismash,代码行数:25,代码来源:domain.py

示例14: from_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def from_biopython(cls: Type[T], bio_feature: SeqFeature, feature: T = None,
                       leftovers: Optional[Dict] = None, record: Any = None) -> T:
        """ Does not return a proper CandidateCluster instance as extra information
            is required from the record in order to properly rebuild it
        """
        if leftovers is None:
            leftovers = Feature.make_qualifiers_copy(bio_feature)

        if not record:
            raise ValueError("record instance required for regenerating CandidateCluster from biopython")

        all_protoclusters = record.get_protoclusters()
        protocluster_numbers = [int(num) for num in leftovers.pop("protoclusters")]

        if max(protocluster_numbers) > len(all_protoclusters):
            raise ValueError("record does not contain all expected protoclusters")

        kind = CandidateClusterKind.from_string(leftovers.pop("kind")[0])
        smiles = leftovers.pop("SMILES", [None])[0]
        polymer = leftovers.pop("polymer", [None])[0]
        children = [all_protoclusters[num - 1] for num in protocluster_numbers]
        return cls(kind, children, smiles, polymer) 
开发者ID:antismash,项目名称:antismash,代码行数:24,代码来源:structures.py

示例15: from_biopython

# 需要导入模块: from Bio import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature import SeqFeature [as 别名]
def from_biopython(cls: Type[T], bio_feature: SeqFeature, feature: T = None,
                       leftovers: Optional[Dict[str, List[str]]] = None, record: Any = None) -> T:
        if leftovers is None:
            leftovers = Feature.make_qualifiers_copy(bio_feature)
        if not feature:
            tool = leftovers.pop("aSTool", [""])[0]
            if not tool:
                return cast(T, ExternalCDSMotif.from_biopython(bio_feature, None, leftovers, record))
            protein_location = generate_protein_location_from_qualifiers(leftovers, record)
            locus_tag = leftovers.pop("locus_tag", ["(unknown)"])[0]
            feature = cls(bio_feature.location, locus_tag, protein_location, tool=tool)

        updated = super().from_biopython(bio_feature, feature, leftovers, record=record)
        assert updated is feature
        assert isinstance(updated, CDSMotif)
        return updated 
开发者ID:antismash,项目名称:antismash,代码行数:18,代码来源:cds_motif.py


注:本文中的Bio.SeqFeature.SeqFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。