Thank you for the prompt reply. I understand that blast, fasta and many other tools are available for this purpose. Since i wanted to learn how to do this in python , and stuck i posted this question
I am new to python and I am having a hard time to figure out how to do this. I have fasta sequences and a few oligo sequences. I would like to align the oligos with the fasta sequences and find percentage similarity of each oligo to each fasta sequence. can any one help me with this
e.g.
fasta sequences
>seq1
cttatatggtaaccgaagcacttcgcccgtataaaaatcatctaaatatgcactttgttt
caaatgtcgatggt
>seq2
tgtttactggcgaaaaaatcaatcgtacagaaaatcgtgccgtgctacatactgcacttc
gcaa
oligos
>x1
ttaacatctgcagcaaaatc
>x2
aaattggggggataccttaa
2 answers
Why are you using python? You can do that with blast/blat/fasta/many_other_aligners. If this a homework, then you need to check RegEx or how a local/global alignment works.
It's not a trivial problem. If you want to do it yourself as a programming exercise, your best bet is to re-implement Needleman-Wunsch or a similar string alignment algorithm.
There's a program in BBTools that will do this. The sequences need to be in fasta format, and all letters need to be uppercase. You can convert to uppercase with reformat:
reformat.sh in=file.fasta out=upper.fasta touppercase
Then run msa:
msa.sh in=upper.fasta out=mapped.sam literal=TTAACATCTGCAGCAAAATC
It will produce exactly one output line per fasta sequence, so you need to run it once per oligo. You can give it a comma-delimited list of oligos instead, in which case there will still be one output line per sequence, but it will be for the oligo that matched best. The output lines will have at the end "YI:f:" followed by a number, indicating the identity. For example, YI:f:97.3 would indicate 97.3% identity.
Log in to answer this question.