contig_annotate.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from falcon_kit.fc_asm_graph import AsmGraph
  2. import sys
  3. def main(argv=sys.argv):
  4. G_asm = AsmGraph("sg_edges_list", "utg_data", "ctg_paths")
  5. p_ctg_coor_map = {}
  6. for fn in ("p_ctg_tiling_path", "a_ctg_tiling_path"):
  7. f = open(fn)
  8. for row in f:
  9. row = row.strip().split()
  10. ctg_id, v, w, edge_rid, b, e = row[:6]
  11. if ctg_id not in p_ctg_coor_map:
  12. coor = 0 # the p_ctg_tiling_path should be sorted by contig the order of the edges in the tiling path
  13. p_ctg_coor_map[ctg_id] = {}
  14. p_ctg_coor_map[ctg_id][v] = 0
  15. coor += abs(int(b) - int(e))
  16. p_ctg_coor_map[ctg_id][w] = coor
  17. G_asm.node_to_ctg[w]
  18. print(ctg_id, v, 0, " ".join(list(G_asm.node_to_ctg[v])))
  19. print(ctg_id, w, coor, " ".join(list(G_asm.node_to_ctg[w])))
  20. continue
  21. else:
  22. coor += abs(int(b) - int(e))
  23. p_ctg_coor_map[ctg_id][w] = coor
  24. print(ctg_id, w, coor, " ".join(list(G_asm.node_to_ctg[w])))
  25. f.close()
  26. if __name__ == "__main__":
  27. main(sys.argv)