def main(): a = parse_args() nodes = os.path.join(a.dir, NODES_IN_FILE) names = os.path.join(a.dir, NAMES_IN_FILE) nodes_out = os.path.join(a.dir, NODES_OUT_FILE) edges_out = os.path.join(a.dir, EDGES_OUT_FILE) with open(nodes) as infile, open(names) as namesfile, open( nodes_out, 'w') as node_out: nodeprov = NCBINodeProvider(namesfile, infile) process_nodes(nodeprov, a.load_version, a.load_timestamp, node_out) with ExitStack() as stack: infile = stack.enter_context(open(nodes)) files = { 1: stack.enter_context(open(edges_out + '_1', 'w')), 2: stack.enter_context(open(edges_out + '_2', 'w')), 3: stack.enter_context(open(edges_out + '_3', 'w')) } edgeprov = NCBIEdgeProvider(infile) for e in edgeprov: e = process_edge(e, a.load_version, a.load_timestamp) fileno = int(e['id']) % 3 + 1 files[fileno].write(json.dumps(e) + '\n')
def main(): a = parse_args() nodes = os.path.join(a.dir, NODES_IN_FILE) names = os.path.join(a.dir, NAMES_IN_FILE) nodes_out = os.path.join(a.dir, NODES_OUT_FILE) edges_out = os.path.join(a.dir, EDGES_OUT_FILE) with open(nodes) as infile, open(names) as namesfile, open(nodes_out, 'w') as node_out: nodeprov = NCBINodeProvider(namesfile, infile) process_nodes(nodeprov, a.load_version, a.load_timestamp, node_out) with open(nodes) as infile, open(edges_out, 'w') as edgef: edgeprov = NCBIEdgeProvider(infile) process_edges(edgeprov, a.load_version, a.load_timestamp, edgef)