Question: Trouble with sliding window for FASTA file in python
1
gravatar for asidhu
10 days ago by
asidhu10
asidhu10 wrote:

I'm struggling to create a sliding window that will loop through sequences (first 30 nucleotides) and identify the forward primer to later trim the primer from the sequences. The file being used as a FASTA file with around 3400 sequences.

filename = "paired.fasta"

min_length = 150
mismatches = 3

fprimer = np.asarray(list("GTGCCAGCMGCCGCGGTAA"))
f_len = len(fprimer)

rprimer = "ACAGCCATGCANCACCT"
rprimer = np.asarray(list(reverse_complement(rprimer)))
r_len = len(rprimer)

forward_region = sequences[0:30]
reverse_region = sequences[-30]
winSizeF = len(forward_region) - len(fprimer) + 1
winSizeR = len(reverse_region) - len(rprimer) + 1

for header, sequence in good_reads.items():
    for i in range(winSizeF):
        start = i
        end = i + len(fprimer)
        target = forward_region[start:end]
        distance = hamming(fprimer, winSizeF)
        if distance == 0:
            break

When I run the for loop I get the following error:

line 103
    """ for header, data in sequences.items():
          ^
SyntaxError: invalid syntax

Any help with this sliding window would be appreciated.

python • 117 views
ADD COMMENTlink written 10 days ago by asidhu10
2

The code with the error is not shown.

line 103
    """ for header, data in sequences.items():
          ^
SyntaxError: invalid syntax
ADD REPLYlink written 10 days ago by WouterDeCoster35k

Your line 103 is not in your example, maybe you missed a paranthesis or a braket before line 103

ADD REPLYlink written 9 days ago by Bastien Hervé2.7k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 731 users visited in the last hour