當前位置: 首頁>>代碼示例>>Python>>正文


Python SeqFeature.FeatureLocation方法代碼示例

本文整理匯總了Python中Bio.SeqFeature.FeatureLocation方法的典型用法代碼示例。如果您正苦於以下問題:Python SeqFeature.FeatureLocation方法的具體用法?Python SeqFeature.FeatureLocation怎麽用?Python SeqFeature.FeatureLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bio.SeqFeature的用法示例。


在下文中一共展示了SeqFeature.FeatureLocation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_point_feature

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [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 FeatureLocation [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 FeatureLocation [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 FeatureLocation [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 FeatureLocation [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 FeatureLocation [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 FeatureLocation [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: test_add_results_to_record

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_add_results_to_record(self):
        pfams = {'PF00015.2': FeatureLocation(0, 3), 'PF00351.1': FeatureLocation(0, 3),
                 'PF00015.27': FeatureLocation(3, 6)}
        fake_record = set_dummy_with_pfams(pfams)
        fake_duplicate_pfam = DummyPFAMDomain(identifier="PF00015.2")
        fake_record.add_pfam_domain(fake_duplicate_pfam)
        assert fake_duplicate_pfam in fake_record.get_pfam_domains()
        gos_for_fake_pfam = pfam2go.get_gos_for_pfams(fake_record)
        fake_results = pfam2go.Pfam2GoResults(fake_record.id, gos_for_fake_pfam)
        fake_results.add_to_record(fake_record)
        assert fake_duplicate_pfam.full_identifier == 'PF00015.2'
        for pfam in fake_record.get_pfam_domains():
            assert sorted(pfam.gene_ontologies.ids) == sorted(fake_results.get_all_gos(pfam))
            # make sure identical pfams (with different version numbers) all have the same gene ontologies
            if pfam.identifier == "PF00015":
                assert pfam.version in [2, 27]
                assert sorted(pfam.gene_ontologies.ids) == sorted(fake_results.get_all_gos(fake_duplicate_pfam)) 
開發者ID:antismash,項目名稱:antismash,代碼行數:19,代碼來源:test_pfam2go.py

示例9: test_to_json

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_to_json(self):
        fake_pfam_location = FeatureLocation(0, 12)
        pfams = {'PF00015': fake_pfam_location, 'PF00351': fake_pfam_location}
        fake_record = set_dummy_with_pfams(pfams)
        gos_for_fake_pfam = pfam2go.get_gos_for_pfams(fake_record)
        fake_results = pfam2go.Pfam2GoResults(fake_record.id, gos_for_fake_pfam)
        result_json = fake_results.to_json()
        expected_result = {"pfams": {"PF00015": {"GO:0007165": "signal transduction",
                                                 "GO:0016020": "membrane"},
                                     "PF00351": {"GO:0016714": ("oxidoreductase activity, acting on paired donors, "
                                                                "with incorporation or reduction of molecular oxygen, "
                                                                "reduced pteridine as one donor, and incorporation of "
                                                                "one atom of oxygen"),
                                                 "GO:0055114": "oxidation-reduction process"}},
                           "record_id": fake_record.id,
                           "schema_version": 1}
        assert result_json["record_id"] == expected_result["record_id"]
        assert result_json["schema_version"] == 1
        for pfam in expected_result["pfams"]:
            assert expected_result["pfams"][pfam] == result_json["pfams"][pfam] 
開發者ID:antismash,項目名稱:antismash,代碼行數:22,代碼來源:test_pfam2go.py

示例10: test_from_wrong_schema

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_from_wrong_schema(self):
        fake_pfam_location = FeatureLocation(0, 12)
        pfams = {'PF00015': fake_pfam_location, 'PF00351': fake_pfam_location, 'PF05147': fake_pfam_location}
        fake_record = set_dummy_with_pfams(pfams)
        broken_json = {"pfams": {"PF00015": {"GO:0004871": "signal transducer activity",
                                             "GO:0007165": "signal transduction",
                                             "GO:0016020": "membrane"},
                                 "PF00351": {"GO:0016714": ("oxidoreductase activity, acting on paired donors, "
                                                            "with incorporation or reduction of molecular oxygen, "
                                                            "reduced pteridine as one donor, and incorporation of "
                                                            "one atom of oxygen"),
                                             "GO:0055114": "oxidation-reduction process"}},
                       "record_id": fake_record.id,
                       "schema_version": 2}
        with self.assertLogs() as log_cm:
            from_broken_json = pfam2go.Pfam2GoResults.from_json(broken_json, fake_record)
            assert "Schema version mismatch, discarding Pfam2GO results" in str(log_cm.output)
            assert not from_broken_json 
開發者ID:antismash,項目名稱:antismash,代碼行數:20,代碼來源:test_pfam2go.py

示例11: test_first_gene_forward

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_first_gene_forward(self, patched_enumerate):
        # ensure coverage only considers this gene of interest
        gene_of_interest = self.add_gene("A", 10, 20, 1)
        patched_enumerate.return_value = [(0, gene_of_interest)]
        other_gene = self.add_gene("B", 30, 40, 1)

        for strand in [1, -1]:
            other_gene.location = FeatureLocation(30, 40, strand)
            print(other_gene.location)

            promoters = self.get_promoters(5, 75)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "A", 5, 20)

            promoters = self.get_promoters(25, 75)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "A", 0, 20)

            promoters = self.get_promoters(5, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "A", 5, 15)

            promoters = self.get_promoters(25, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "A", 0, 15) 
開發者ID:antismash,項目名稱:antismash,代碼行數:27,代碼來源:test_promoters.py

示例12: test_last_gene_forward

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_last_gene_forward(self, patched_enumerate):
        other_gene = self.add_gene("A", 10, 20, 1)
        # ensure coverage only considers this gene of interest
        gene_of_interest = self.add_gene("B", 30, 40, 1)
        patched_enumerate.return_value = [(1, gene_of_interest)]

        for strand in [1, -1]:
            other_gene.location = FeatureLocation(10, 20, strand)
            print(other_gene.location)

            promoters = self.get_promoters(5, 75)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 25, 40)

            promoters = self.get_promoters(25, 75)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 21, 40)

            promoters = self.get_promoters(5, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 25, 35)

            promoters = self.get_promoters(25, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 21, 35) 
開發者ID:antismash,項目名稱:antismash,代碼行數:27,代碼來源:test_promoters.py

示例13: test_normal_case_forward

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_normal_case_forward(self, patched_enumerate):
        other = self.add_gene("A", 10, 20, 1)
        gene_of_interest = self.add_gene("B", 40, 60, 1)
        self.add_gene("C", 70, 80, 1)
        patched_enumerate.return_value = [(1, gene_of_interest)]

        for strand in [-1, 1]:
            other.location = FeatureLocation(other.location.start, other.location.end, strand)

            promoters = self.get_promoters(5, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 35, 45)

            promoters = self.get_promoters(5, 25)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 35, 60)

            promoters = self.get_promoters(25, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 21, 45)

            promoters = self.get_promoters(25, 25)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 21, 60) 
開發者ID:antismash,項目名稱:antismash,代碼行數:26,代碼來源:test_promoters.py

示例14: test_normal_case_reverse

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def test_normal_case_reverse(self, patched_enumerate):
        self.add_gene("A", 10, 20, 1)
        gene_of_interest = self.add_gene("B", 40, 60, -1)
        other = self.add_gene("C", 70, 80, -1)
        patched_enumerate.return_value = [(1, gene_of_interest)]

        for strand in [-1]:
            other.location = FeatureLocation(other.location.start, other.location.end, strand)

            promoters = self.get_promoters(5, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 55, 65)

            promoters = self.get_promoters(5, 25)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 40, 65)

            promoters = self.get_promoters(25, 5)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 55, 69)

            promoters = self.get_promoters(25, 25)
            assert len(promoters) == 1
            self.check_single_promoter(promoters[0], "B", 40, 69) 
開發者ID:antismash,項目名稱:antismash,代碼行數:26,代碼來源:test_promoters.py

示例15: get_aa_translation_from_location

# 需要導入模塊: from Bio import SeqFeature [as 別名]
# 或者: from Bio.SeqFeature import FeatureLocation [as 別名]
def get_aa_translation_from_location(self, location: FeatureLocation,
                                         transl_table: Union[str, int] = None) -> Seq:
        """ Obtain the translation for a feature based on its location """
        if location.end > len(self.seq):
            raise ValueError("location outside available sequence")
        if transl_table is None:
            transl_table = self._transl_table
        extracted = location.extract(self.seq).ungap('-')
        if len(extracted) % 3 != 0:
            extracted = extracted[:-(len(extracted) % 3)]
        seq = extracted.translate(to_stop=True, table=transl_table)
        if not seq:
            # go past stop codons and hope for something to work with
            seq = extracted.translate(table=transl_table)

        # replace ambiguous proteins with an explicit unknown
        string_version = str(seq)
        for invalid in "*BJOUZ":
            string_version = string_version.replace(invalid, "X")
        seq = Seq(string_version, Alphabet.generic_protein)

        if "-" in str(seq):
            seq = Seq(str(seq).replace("-", ""), Alphabet.generic_protein)
        return seq 
開發者ID:antismash,項目名稱:antismash,代碼行數:26,代碼來源:record.py


注:本文中的Bio.SeqFeature.FeatureLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。