Skip to content

Instantly share code, notes, and snippets.

@dogrunjp
Last active November 1, 2017 00:52
Show Gist options
  • Save dogrunjp/3e81febee323aca97a05c2cdaf9d2656 to your computer and use it in GitHub Desktop.
Save dogrunjp/3e81febee323aca97a05c2cdaf9d2656 to your computer and use it in GitHub Desktop.
create edge_list from tsv
import csv
csv.field_size_limit(1000000000)
with open("sra_edge_list.tsv", "w") as out_f:
writer = csv.writer(out_f, delimiter="\t")
with open("SRA_Accessions.tab", "r") as input_f:
reader = csv.reader(input_f, delimiter="\t")
reader.next()
for l in reader:
try:
acc = l[0]
ex = l[10]
sa = l[11]
st = l[12]
bs = l[17]
bp = l[18]
writer.writerow([acc, ex])
writer.writerow([acc, sa])
writer.writerow([acc, st])
writer.writerow([acc, bs])
writer.writerow([acc, bp])
except:
pass
import csv
csv.field_size_limit(1000000000)
with open("sra_edge_list2.tsv", "w") as out_f:
writer = csv.writer(out_f, delimiter="\t")
with open("SRA_Accessions.tab", "r") as input_f:
reader = csv.reader(input_f, delimiter="\t")
reader.next()
for l in reader:
try:
acc = l[0]
dest = [l[10], l[11], l[12], l[17], l[18]]
for x in dest:
if x != "-":
writer.writerow([acc, x])
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment