• +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Online Customer Service
Follow Us:

Python Programming: Write a program that will open a BLASTN

Write a program that will open a BLASTN (nucleotide to nucleotide search) output file, parse out specific information, and produce formatted output that will be written to STDOUT (i.e. Standard Output; the terminal window / command line).

Your program should start by opening the input file (you may hardcode the filename in this case), parsing and storing both the query sequence ID (from near the top of the file; look for the string following “Query=“) and the query length (found on the line below the query sequence), and displaying them both to STDOUT. Add some additional characters and formatting to your output such that these two fields appear exactly like this in STDOUT:


Query Length: 15

Then, it is time to parse information about the significant alignments for this query. Each alignment begins with the “>” symbol. For just the first ten hits, parse out only the accession (located between the first set of pipe symbols, | | ), length and score. For each of these hits, these three fields should then be written to STDOUT in exactly this format including capitalization, spacing, and punctuation (as shown here using the real values for the first hit; study the file to understand exactly where these values came from):

Alignment #1: Accession = ref|XM_005094338.1| (Length = 2377, Score = 1098)

You must use regular expressions to pull out precisely the parts of the file that you want, which is the definition of parsing. Hint: you will very likely need to use parentheses to put some parts of those expressions into temporary memory (m.group(1), etc.) for later use. Do not have your regular expression search for hardcoded values; your program should be able to read another BLASTN output file and run successfully, not just this specific one. Pay careful attention to the exact appearance of the sample output, above. Although it is a good start to be able to, at a minimum, report the requested values, your program must also strive to match the formats specified.

Example blastn layout below.

Write a program that will open a BLASTN Image 1
Write a program that will open a BLASTN Image 2
Write a program that will open a BLASTN Image 3
Tap to Chat
Get Instant Assignment Help
Tap to Chat
Get Instant Assignment Help