[Biopython] Specifying variable bases in search sequences.
"Ryan J. Hope" <[email protected]>
| Newsgroups | gmane.comp.python.bio.general |
|---|---|
| Message-ID | <[email protected]> |
Hello everyone, I have a script which searches fasta files for -10 and -35 consensus sequences. In my -10 sequence only 2 out of the 6 bases are conserved. How may I search for variable bases for the 4 which are not conserved. I have tried using ’n’ in place of an actual base however this doesn’t produce any results. See .py file attached. Kind regards, Ryan. _______________________________________________ Biopython mailing list - [email protected] http://mailman.open-bio.org/mailman/listinfo/biopython
promotor_search_variable-10.py
(text/x-python-script, 1 KB)
from Bio import SeqIO
from Bio.Seq import Seq
#Enter -35 into forseq, -10 into revseq#
#Define filename variable as filepath#
forseq = Seq("tttaca".upper())
revseq = Seq("ntnntn".upper())
filename = "/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C_aceto/NC_003030.1.fasta"
#In range field enter gap range between -35 and -10 binding sites#
forcom = forseq.reverse_complement()
revcom = revseq.reverse_complement()
print("seq\tstart\tstop\tgap\tdir\tseq")
for record in SeqIO.parse(filename, "fasta"):
for i in range(len(record.seq)):
for v1, v2, direc in [ (forseq, revseq, "F"), (revcom, forcom, "R") ]:
if record.seq[i:i+len(v1)] == v1:
for j in range(10,25):
if record.seq[i+len(v1)+j:i+len(v2)+j+len(v2)] == v2:
print("{}\t{}\t{}\t{}\t{}\t{}".format(
record.id, i,
i + len(v1)+j+len(v2)-1,
j, direc,
record.seq[i: i+len(v1) + j + len(v2)] ))