Question

In Python Copy the sequence below to a text editor (say notepad), as the sequences as...

In Python

Copy the sequence below to a text editor (say notepad), as the sequences as a text file (.txt). Then, write a python script, to read the file you have saved. The script should count the number of lines in the file and print the number. The script should also separate the annotation lines from the DNA sequences, and save the content of the annotations to a file (The file written by your script should content the lines in red here).

>gi|188989396|ref|NC_010688.1| Xanthomonascampestrispv. campestris, complete genome

ATGGATGCTTGGCCCCGCTGTCTGGAACGTCTCGAAGCTGAATTCCCGCCCGAAGATGTCCACACCTGGT

TGAAACCCCTGCAGGCCGAAGATCGCGGCGACAGCATCGTGCTGTACGCGCCGAACGCCTTCATTGTCGA

GCAGGTTCGCGAGCGATACCTGCCGCGCATCCGCGAGTTGCTGGCGTATTTCGCCGGCAATGGCGAGGTG

>gi|194208364|ref|XM_001500342.2| PREDICTED: Equuscaballuselectron-transferring-flavoprotein…

GATACGTGACCCGGAAGCCTCTGCTGGCCATGGCGTCATGCGTGGCGCCGGCGCAGAGCGAGAGAGAGTC

GGGAGCGCTGTGAAGACAGAGCGGTCGGCTGATCAGAGACGAACTTCAGTGGAGGTGATGGCGCCCCCCG

CGGCCTAGAGGTCCAGAGCGTGCCGCGAGCTGCAGACAGTACGCCTCCCATTGTATCCGACGGAGACTCC

TCGTTGCAGGGAACATGTTGCTGCCGCTAGCCAAGCTGTCCTGTCCGGCATATCAGTGCTTTCATGCCTT

AAAAATTAAGAAAGATTATCTACCTCTGTGTGCTACAAGATGGTCTTCAACTTCTGTTGTACCTCGAATT

>gi|193087197|gb|CP001100.1| ChloroherpetonthalassiumATCC 35110, complete genome

ATGCTTATGAGCGAAGGACATGACCAGCCAGGCGCTCCTGTTTCTCATTTATCGGAACAGGCTTTAGCAC

AAATTGCGTGGAAAAAATGCCTCGATATCATTCGTGATGGCCTTCATAACCTGCAAAGCTTTAAGACTTG

GTTTGAGCCCATCGTGCCATTAAAACTTTCTGGCCAGGAATTGACCATTCAGGTGCCCAGCCAGTTTTTT

TATGAAATGATCGAGGAAAATTATTACTCGCTTTTAAAGCGCGCCTTGATGGAAGTGATGGGAACGGGAG

CCAAGCTGCGATATTCTGTTTTGGTTCAGGCGGCACAAGCTGAAACACCCGTCGTCGCTCGTATCCCCGA

GAAAAAAGGCAAGCACACTCCGGCGGCGCTTCCGAAAGTCATTTCTCATGCGAATGGCAAGCAGACAAAA

GAAGCTCAAGACTTATTTGCAAACAATGTACACCGCTTCGAAAGCTACCTAAATCCAAAATATCGCTTCG

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

Output:

Note: cat output.txt means printing the output.txt file data.

file.txt:

Raw Code:

file = "file.txt" # File name
file_data = open(file,"r") # opening file
file_out = open("output.txt","w") # Creating a new file for writing output
file_lines = file_data.readlines() # Reading data line by line from file
line_count =0 # Creating variable for counting no of lines in a file
for line in file_lines: # Each line in file_lines
   if(line[0]==">"): # Checking if a line start's with ">" or not
       file_out.write(line) # Writing annotation lines to file_out
   line_count = line_count + 1 # Incrementing line_count
print("The no of lines in a file: " + str(line_count)) # Printing no of lines in a file

Add a comment
Know the answer?
Add Answer to:
In Python Copy the sequence below to a text editor (say notepad), as the sequences as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT