Question: Python Question: A bioinformatics lab mixed up DNA sequences in a single data file for two organisms: fruit fly and a grape. Create a Python

Python Question:

A bioinformatics lab mixed up DNA sequences in a single data file for two organisms: fruit fly and a grape. Create a Python program that reads the sequences from a text file (one per line), performs a BLAST search if not previously done, stores the results of each search in a separate file, and then performs analytics on the search results to help solve our sequence mix-up problem. Details:

Place the text file (name DNA.txt) in your local directory for reading. Each line of the data file contains a DNA sequence. There are 10 sequences in the file.

Read each line of the data file and print to the console the first 20 characters in the sequence and the length of the query sequence.

Use a counter to keep track of how many sequences have been processed.

Using a try-except clause, look for a previously created BLAST result file that should be named dna_count.xml. For example, dna_1.xml. Start the number from 1.

If the file exists, open it. Print "Using saved file".

If the file does not exist or there is an error, perform a BLAST search using the sequence given. Print "Performing online BLAST search". Note that you will have to import some modules from Biopython which are not already installed with Anaconda. To install with Anaconda, run this command:

conda install -c https://conda.anaconda.org/anaconda biopython

Libraries to import:

from Bio.Blast import NCBIWWW from Bio.Blast import NCBIXML

The methods are given:

from Bio.Blast import NCBIWWW,NCBIXML 
import fileinput outputList = [] matchedSize = [] for line in fileinput.input(): result_handle = NCBIWWW.qblast("blastn", "nt", line) 

blast_record = NCBIXML.parse(request_handle)

if(blast_record.alignments[0].title==grape)

outputList.append(1)

else outputList.append(0)

matchedSize.append(blast_record.alignments[0].length)

Thank you very much.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!