Last active
November 1, 2017 00:52
-
-
Save dogrunjp/3e81febee323aca97a05c2cdaf9d2656 to your computer and use it in GitHub Desktop.
create edge_list from tsv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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