<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Demonstration of the Dseqrecord object
Step1:  A small Dseqrecord object can be created directly. The Dseqrecord class is a double stranded version of the Biopython SeqRecord class.
Step2:  The representation below indicate the size of the sequence and the fact that it is linear (- symbol).
Step3:  The Dseqrecord class is the main pydna data type together with the Dseq class. The sequence information is actually held by an internal Dseq object that is accessible from the .seq property
Step4:  Dseqrecords can be read from local files in several formats
Step5:  The sequence files above all contain the same sequence. We can print the sequence by the .seq property.
Step6:  We can also read from a string defined directly in the code
Step7:  We can also download sequences from genbank if we know the accession number. The plasmid pUC19 has the accession number L09137. We have to give pydna a valid email address before we use Genbank in this way. Please change the email address to your own when executing this script. Genbank require to be able to contact its users if there is a problem.
Step8:  This molecule is circular so the representation below begins with a "o". The size is 2686 bp.
Step9:  We can also read sequences remotely from other web sites for example this sequence for YEplac181
Step10:  Dseqrecord supports the same kind of digestion / ligation functionality as shown for Dseq.
Step11:  Finally, we can save Dseqrecords in a local file. The default format is Genbank.
<ASSISTANT_TASK:>
Python Code:
from pydna.dseqrecord import Dseqrecord
Explanation: Demonstration of the Dseqrecord object
End of explanation
mysequence = Dseqrecord("GGATCCAAA")
Explanation: A small Dseqrecord object can be created directly. The Dseqrecord class is a double stranded version of the Biopython SeqRecord class.
End of explanation
mysequence
Explanation: The representation below indicate the size of the sequence and the fact that it is linear (- symbol).
End of explanation
mysequence.seq
from pydna.readers import read
Explanation: The Dseqrecord class is the main pydna data type together with the Dseq class. The sequence information is actually held by an internal Dseq object that is accessible from the .seq property:
End of explanation
read_from_fasta = read("fastaseq.fasta")
read_from_gb = read("gbseq.gb")
read_from_embl = read("emblseq.emb")
Explanation: Dseqrecords can be read from local files in several formats
End of explanation
print(read_from_fasta.seq)
print(read_from_gb.seq)
print(read_from_embl.seq)
Explanation: The sequence files above all contain the same sequence. We can print the sequence by the .seq property.
End of explanation
read_from_string = read('''
>seq_from_string
GGATCCAAA
''')
Explanation: We can also read from a string defined directly in the code:
End of explanation
from pydna.genbank import Genbank
gb = Genbank("bjornjobb@gmail.com")
pUC19 = gb.nucleotide("L09137")
Explanation: We can also download sequences from genbank if we know the accession number. The plasmid pUC19 has the accession number L09137. We have to give pydna a valid email address before we use Genbank in this way. Please change the email address to your own when executing this script. Genbank require to be able to contact its users if there is a problem.
End of explanation
pUC19
from pydna.download import download_text
Explanation: This molecule is circular so the representation below begins with a "o". The size is 2686 bp.
End of explanation
text = download_text("https://gist.githubusercontent.com/BjornFJohansson/e445e5039d61bdcdf933c435438b4585/raw/a6d57a8d5cffcbf0ab76307c82746e5b7265d0c8/YEPlac181snapgene.gb")
YEplac181 = read(text)
YEplac181
Explanation: We can also read sequences remotely from other web sites for example this sequence for YEplac181:
End of explanation
from Bio.Restriction import BamHI
a, b = mysequence.cut(BamHI)
a
b
a.seq
b.seq
a+b
Explanation: Dseqrecord supports the same kind of digestion / ligation functionality as shown for Dseq.
End of explanation
mysequence.write("new_sequence.gb")
Explanation: Finally, we can save Dseqrecords in a local file. The default format is Genbank.
End of explanation
<END_TASK>