annotate changespacetounderscore_readname.py @ 12:a3113043abb0 draft

Uploaded
author arkarachai-fungtammasan
date Sun, 24 Jul 2016 17:55:50 -0400
parents 07588b899c13
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
1 import sys
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
2 fd=open(sys.argv[1])
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
3 output=open(sys.argv[2],'w')
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
4 columntochange=int(sys.argv[3])-1 # default is 6-1=5
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
5 lines=fd.xreadlines()
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
6 for line in lines:
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
7 temp=line.strip().split('\t')
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
8 temp=filter(None,temp)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
9 temp2=temp[columntochange].replace(' ','_')
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
10 product=temp[:columntochange]
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
11 product.append(temp2)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
12 product.extend(temp[columntochange+1:])
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
13 output.writelines('\t'.join(product)+'\n')
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
14 fd.close()
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
15 output.close()