Skip to content

How do I re-write data into a snapgene file? #9

Description

@li1311139481
from snapgene_reader import snapgene_file_to_dict, snapgene_file_to_seqrecord
from Bio.Seq import Seq

file_path = "/cluster/facility/hlhuang/zifeng001/snapgene/LMB.dna"
dictionary = snapgene_file_to_dict(file_path)
seqrecord = snapgene_file_to_seqrecord(file_path)

for i, value in dictionary.items():
    # print(value)
    if isinstance(value, list):
        # print(value)
        for anno in value:
            # print(anno)
            if anno["name"] == "sgRNA":
                # print(anno["name"])
                start = anno["start"]
                end = anno["end"]

dictionary["seq"] = dictionary["seq"].replace(
    dictionary["seq"][start:end], new_sgRNA_sequence
)

I used this code to find and replace the sequence. Then I want to regenerate the snapgene file. What should I do?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions