Commit e68a0331 authored by Midoux Cedric's avatar Midoux Cedric
Browse files

Combine duplicates lines with comma

parent c14c9cd5
......@@ -54,3 +54,30 @@ done < <(sed '/^[#!+]/d;s/<[^>]*>//g;s/^./& /' < "$kegfile") > KO_Orthology_ko00
rm ko00001.keg
```
### Combine duplicates lines with comma
```python
import csv
import os
os.system("sort -k1,1 user_ko.txt > user_ko-sort.txt")
with open("user_ko-sort.txt", "r") as f:
with open("user_ko-uniq.txt", "w") as out:
reader=csv.reader(f, delimiter='\t')
old_gene=""
old_ko=""
for row in reader:
gene=row[0]
try:
ko=row[1]
except IndexError:
ko="NA"
if(gene==old_gene):
old_ko=old_ko+","+ko
else:
out.write("%s\t%s\n"%(old_gene, old_ko))
old_gene=gene
old_ko=ko
out.write("%s\t%s\n"%(gene, ko))
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment