Hello everyone, I wrote a post awhile ago about automating a local client to access a BLAT webserver, but today I have a much easier one. I want to take a batch file and delete every odd line. See below:
Sample File:
>Musmusculusm iR-344
UGAUCUAGCCAAAGC CUGACUGU
>Musmusculusm iR-345
UGCUGACCCCUAGUC CAGUGC
>Musmusculusm iR-346
UGUCUGCCCGAGUGC CUGCCUCU
>Musmusculusm iR-350
UUCACAAAGCCCAUA CACUUUCA
I need to delete all the lines that start with '>' and end with a '\n'. I have some code below, but it just isolates the part of the string I want to delete. I need to do the reverse... I know there is some easy way that I am totally missing here!
Thanks,
Mark
Sample File:
>Musmusculusm iR-344
UGAUCUAGCCAAAGC CUGACUGU
>Musmusculusm iR-345
UGCUGACCCCUAGUC CAGUGC
>Musmusculusm iR-346
UGUCUGCCCGAGUGC CUGCCUCU
>Musmusculusm iR-350
UUCACAAAGCCCAUA CACUUUCA
I need to delete all the lines that start with '>' and end with a '\n'. I have some code below, but it just isolates the part of the string I want to delete. I need to do the reverse... I know there is some easy way that I am totally missing here!
Code:
#!/usr/bin/env python
# written 7/28/2007
# by Mark O'Connor
def Resize( filename ):
line = 0
collect = []
fp = file( filename )
data = fp.read()
fp.close()
#print data
while line != -1:
start = data.find('>', line+1)
end = data.find ('/n', start)
chunk = data[start:end]
return chunk
Mark
Comment