Question: SNPs detection through python
0
gravatar for anasjamshed1994
11 weeks ago by
anasjamshed199460 wrote:

I want to create Python programs with the following specifications:

Purpose: Given a DNA sequence alignment, print to the screen any positions containing a putative polymorphism (transition, transversion or indel). The threshold for the polymorphic allele is defined by the user. The screen output will have the position and the two alleles with their counts and the minor allele frequency in an easy to read format.

The program will have the following command-line structure:
        findSNPs.py<input MSA><minor allele frequency threshold>

• input MSA – a DNA multiple sequence alignment in FASTA format • minor allele frequency threshold – To call an SNP at a position, a second allele must be present in at least this frequency. NOTE: Only A, T, C, and G are valid alleles. All other letters should be ignored.

I tried this scripts but no SNPs found:

from Bio import AlignIO

y=0
alignment = AlignIO.read("DNA_alignment.fasta", "fasta")
#print(alignment.get_alignment_length())
for r in range(0,len(alignment[2].seq)):
    if alignment[0,r] != alignment[1,r]:
        if alignment[0,r] != "-" and alignment[1,r] != "-":
            y=y+1
            print (r, alignment[0,r], alignment[1,r], y)
        else:
            y=0

from snps import SNPs
a= SNPs(alignment)
a.snp_count

How can I solve this problem?

dna snp python • 283 views
ADD COMMENTlink modified 11 weeks ago by Alex Reynolds31k • written 11 weeks ago by anasjamshed199460

Can anyone plz help me?

ADD REPLYlink written 11 weeks ago by anasjamshed199460

Hello Dear.

Please try this one:

from Bio import AlignIO
y=0
alignment = AlignIO.read("DNA_alignment.fasta", "fasta")
for r in range(0,len(alignment[1].seq)):
    if alignment[0,r] != alignment[1,r]:
        if alignment[0,r] != "-" and alignment[1,r] != "-":
            y=y+1
            print (r, alignment[0,r], alignment[1,r], y)
        else:
              y=0

Hope that can help you.

ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by angez99140
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: 1411 users visited in the last hour
_