The Biopython programming language is an open-source application programming interface (API) used both in bioinformatics software development and in everyday scripts to perform common bioinformatics tasks.
import os
os.chdir("C:/Users/manso/OneDrive - University of West London/MSc Bioinformatics - UWL/3.DSB - Data Science for Bioinformatics/Practice/DSB W4")
from Bio.Seq import Seq #seq objects
from Bio import SeqIO #SeqRecord objects
new_seq = Seq ("AGGTACCAGGTAG")
print(new_seq)
AGGTACCAGGTAG
for seq_record in SeqIO.parse("TestFasta1.fa", "fasta"):
print ("fasta header:", seq_record.id)
print(repr(seq_record.seq))
print("seq length", len( seq_record))
fasta header: TestFasta Seq('AGAAAGAACAAGCTCCTCCCCATGGTAACTCGG') seq length 33
MySeq = seq_record.seq
print(MySeq)
AGAAAGAACAAGCTCCTCCCCATGGTAACTCGG
MySeq.find("AAC")
6
MySeq.find("TAG")
-1
MySeq.count("G")
7
MySeq.count("ACC")
0
print(MySeq)
AGAAAGAACAAGCTCCTCCCCATGGTAACTCGG
MySeq.complement()
Seq('TCTTTCTTGTTCGAGGAGGGGTACCATTGAGCC')
MySeq.reverse_complement()
Seq('CCGAGTTACCATGGGGAGGAGCTTGTTCTTTCT')
MyRNA = MySeq.transcribe()
MyRNA.back_transcribe()
Seq('AGAAAGAACAAGCTCCTCCCCATGGTAACTCGG')
MyRNA.translate()
Seq('RKNKLLPMVTR')
MySeq.translate()
Seq('RKNKLLPMVTR')