This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
thesis_tm/bfs_subgraph_extractor.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (23 sloc)
763 Bytes
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 sys | |
import os | |
from functions import write_gfa, bfs | |
from Graph import Graph | |
if len(sys.argv) < 5: | |
print("You need to give 4 arguments, [input_gfa] [size_of_neighborhood] " | |
"[output_file] [one or several starting points]") | |
sys.exit(0) | |
if os.path.isfile(sys.argv[1]): | |
print("reading file...\n") | |
new_graph = Graph() | |
new_graph.read_gfa(sys.argv[1]) | |
starting_points = [] | |
output_g = [] | |
for arg in sys.argv[4:]: | |
starting_points.append(int(arg)) | |
for start in starting_points: | |
path = bfs(new_graph.nodes, start, int(sys.argv[2])) | |
output_g += path | |
write_gfa(nodes=new_graph.nodes, list_of_nodes=output_g, output_file=sys.argv[3]) | |
else: | |
print("The file doesn't exist") | |
sys.exit() |