I'm trying to take a file that looks like this:
taxon1
ACCGTGGATC
CCTATTGATT
GGATATTATC
taxon2
TTCATATGTA
GGATTTCATA
GATGGCCCCC
And get it to look like this
taxon1 ACCGTGGATCCCTATTGATTGGATATTATC
I'm using a python script, so far this is what I have:
#!/usr/bin/python
import sys
if len(sys.argv) < 2:
print "usage: finalmyscript.py infile.txt"
sys.exit(1)
fname = sys.argv[1]
handle = open(fname, "r")
list = handle.readlines()
for line in list:
parts = line.rstrip('\n')
linearr = parts.split()
combine = ''.join(linearr[0])
print combine
handle.close()
The script removes the '\n' at the end of each line, but it still won't join the lines all on a single line. Can anyone help with where I'm going wrong?
Thanks!