def test_prepeptide_adjustment(self): dummy_record = Record(Seq("A"*400, generic_dna)) subregion = DummySubRegion(start=100, end=300) dummy_record.add_subregion(subregion) region = Region(subregions=[subregion]) dummy_record.add_region(region) dummy_prepeptide = DummyFeature(200, 230, 1, "CDS_motif") # ensure both FeatureLocation and CompoundLocations are handled appropriately leader_loc = FeatureLocation(200, 210, 1) tail_loc = CompoundLocation([FeatureLocation(220, 223, -1), FeatureLocation(227, 230, -1)]) dummy_prepeptide._qualifiers["leader_location"] = [str(leader_loc)] dummy_prepeptide._qualifiers["tail_location"] = [str(tail_loc)] dummy_record.add_feature(dummy_prepeptide) # and add a CDS_motif without either qualifier (e.g. NRPS/PKS motif) to ensure that doesn't break dummy_record.add_feature(DummyFeature(250, 280, 1, "CDS_motif")) with NamedTemporaryFile(suffix=".gbk") as output: region.write_to_genbank(output.name) bio = list(seqio.parse(output.name))[0] assert len(bio.features) == 4 found = False for feature in bio.features: tail = feature.qualifiers.get("tail_location") leader = feature.qualifiers.get("leader_location") if tail and leader: # the part locations should now be adjusted backwards 100 bases assert leader == ["[100:110](+)"] assert tail == ["join{[120:123](-), [127:130](-)}"] found = True assert found, "prepeptide feature missing in conversion"
def add_to_record(self, record: Record) -> None: """ Adds the found TTA features to the record """ if record.id != self.record_id: raise ValueError( "Record to store in and record analysed don't match") for feature in self.features: record.add_feature(feature)
def add_to_record(self, record: Record) -> None: """ Adds the hits as TIGRDomains to the given record """ if record.id != self.record_id: raise ValueError("Record to store in and record analysed don't match") for i, hit in enumerate(self.hits): protein_location = FeatureLocation(hit.protein_start, hit.protein_end) tigr_feature = TIGRDomain(location_from_string(hit.location), description=hit.description, protein_location=protein_location, identifier=hit.identifier, locus_tag=hit.locus_tag) for key in ["label", "locus_tag", "domain", "evalue", "score", "translation"]: setattr(tigr_feature, key, getattr(hit, key)) tigr_feature.detection = "hmmscan" tigr_feature.domain_id = "{}_{}_{:04d}".format(self.tool, tigr_feature.locus_tag, i + 1) record.add_feature(tigr_feature)
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)