String search and write into file in jython

Posted by kdev on Stack Overflow See other posts from Stack Overflow or by kdev
Published on 2010-03-24T02:03:44Z Indexed on 2010/03/24 2:13 UTC
Read the original article Hit count: 539

Filed under:
|

hi Everyone ,

i wish to write a program that can read a file and if a particular str_to_find is found in a bigger string say AACATGCCACCTGAATTGGATGGAATTCATGCGGGACACGCGGATTACACCTATGAGCAGAAATACGGCCTGCGCGATTACCGTGGCGGTGGACGTTCTTCCGCGCGTGAAACCGCGATGCGCGTAGCGGCAGGGGCGATCGCCAAGAAATACCTGGCGGAAAAGTTCGGCATCGAAATCCGCGGCTGCCTGACCCAGATGGGCGACATTCCGCTGGAGATTAAAGACTGGCGTCAGGTTGAGCTTAATCCGTTTTC then write that line and the above line of it into the file and keep repeating it for all the match found.

Please suggest i have written the program for printing that particular search line but i dont know how to write the above line.

Thanks everyone for your help.

import re
import string
file=open('C:/Users/Administrator/Desktop/input.txt','r')
output=open('C:/Users/Administrator/Desktop/output.txt','w')
count_record=file.readline()
str_to_find='AACCATGC'
while count_record:
 if  string.find(list,str_to_find) ==0:
  output.write(count_record)

file.close()
output.close()

© Stack Overflow or respective owner

Related posts about jython

Related posts about string