def main(): parser = argparse.ArgumentParser(description='Creating GraphML') parser.add_argument('input_pairs', help='input_pairs') parser.add_argument('input_clusterinfosummary', help='input_clusterinfosummary') parser.add_argument('input_librarysearch', help='input_librarysearch') parser.add_argument('output_graphml', help='output_graphml') parser.add_argument('--input_analoglibrarysearch', help='input_analoglibrarysearch') parser.add_argument('--input_pairsfolder', help='input_pairsfolder') args = parser.parse_args() #Doing other filtering G = molecular_network_filtering_library.loading_network(args.input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph( G, args.input_clusterinfosummary) molecular_network_filtering_library.add_library_search_results_to_graph( G, args.input_librarysearch) if args.input_pairsfolder is not None: all_pairs_files = glob.glob(os.path.join(args.input_pairsfolder, "*")) for additional_pairs_file in all_pairs_files: print("Adding Additional Edges", additional_pairs_file) molecular_network_filtering_library.add_additional_edges( G, additional_pairs_file) if args.input_analoglibrarysearch is not None: molecular_network_filtering_library.add_library_search_results_to_graph( G, args.input_librarysearch, annotation_prefix="Analog:") nx.write_graphml(G, args.output_graphml, infer_numeric_types=True)
def main(): input_pairs = sys.argv[1] #Doing other filtering G = molecular_network_filtering_library.loading_network(input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph(G, sys.argv[2]) molecular_network_filtering_library.add_library_search_results_to_graph(G, sys.argv[3]) nx.write_graphml(G, sys.argv[4])
def main(): input_pairs = sys.argv[1] #Doing other filtering G = molecular_network_filtering_library.loading_network(input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph( G, sys.argv[2]) molecular_network_filtering_library.add_library_search_results_to_graph( G, sys.argv[3]) nx.write_graphml(G, sys.argv[4], infer_numeric_types=True)
def create_graphml(input_pairs, input_clusterinfosummary, input_librarysearch, input_analoglibrarysearch, input_pairsfolder, output_graphml, collapse_ion_edges=False): logger = logging_utils.get_logger(__name__) # Doing other filtering logger.debug("Creating network") G = molecular_network_filtering_library.loading_network(input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph( G, input_clusterinfosummary) molecular_network_filtering_library.add_library_search_results_to_graph( G, input_librarysearch) # mark all nodes as feature or ion identity nodes (constants.NODE.TYPE_ATTRIBUTE) logger.debug("Mark all node types") ion_network_utils.mark_all_node_types(G) # add analogs if input_analoglibrarysearch is not None: logger.debug("Add analog library search results") molecular_network_filtering_library.add_library_search_results_to_graph( G, input_analoglibrarysearch, annotation_prefix="Analog:") # add additional edges - e.g. ion identity edges between different ion species of the same molecule if input_pairsfolder is not None: all_pairs_files = glob.glob(os.path.join(input_pairsfolder, "*")) logger.debug("Adding additional edges from files: " + str(len(all_pairs_files))) for additional_pairs_file in all_pairs_files: logger.debug("Adding Additional Edges from " + str(additional_pairs_file)) molecular_network_filtering_library.add_additional_edges( G, additional_pairs_file) # collapse all ion identity networks, each into a single node if collapse_ion_edges: logger.debug("Collapsing additional edges of type: " + CONST.EDGE.ION_TYPE) try: G = ion_network_utils.collapse_ion_networks(G) except: logger.debug("Failed collapsing") pass # export graphml logger.info("Writing graphml: " + output_graphml) nx.write_graphml(G, output_graphml, infer_numeric_types=True)
def main(): input_pairs = sys.argv[1] #Doing other filtering G = molecular_network_filtering_library.loading_network(input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph(G, sys.argv[2]) molecular_network_filtering_library.add_library_search_results_to_graph(G, sys.argv[3]) folder_for_additional_pairs = sys.argv[4] all_pairs_files = ming_fileio_library.list_files_in_dir(folder_for_additional_pairs) for additional_pairs_file in all_pairs_files: print("Adding Additional Edges", additional_pairs_file) molecular_network_filtering_library.add_additional_edges(G, additional_pairs_file) nx.write_graphml(G, sys.argv[5], infer_numeric_types=True)
def main(): input_pairs = sys.argv[1] #Doing other filtering G = molecular_network_filtering_library.loading_network(input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph( G, sys.argv[2]) molecular_network_filtering_library.add_library_search_results_to_graph( G, sys.argv[3]) folder_for_additional_pairs = sys.argv[4] all_pairs_files = ming_fileio_library.list_files_in_dir( folder_for_additional_pairs) for additional_pairs_file in all_pairs_files: print("Adding Additional Edges", additional_pairs_file) molecular_network_filtering_library.add_additional_edges( G, additional_pairs_file) nx.write_graphml(G, sys.argv[5], infer_numeric_types=True)
def create_graphml(input_pairs, input_clusterinfosummary, input_librarysearch, input_analoglibrarysearch, input_pairsfolder, output_graphml): #Doing other filtering G = molecular_network_filtering_library.loading_network(input_pairs, hasHeaders=True) molecular_network_filtering_library.add_clusterinfo_summary_to_graph( G, input_clusterinfosummary) molecular_network_filtering_library.add_library_search_results_to_graph( G, input_librarysearch) if input_pairsfolder is not None: all_pairs_files = glob.glob(os.path.join(input_pairsfolder, "*")) for additional_pairs_file in all_pairs_files: print("Adding Additional Edges", additional_pairs_file) molecular_network_filtering_library.add_additional_edges( G, additional_pairs_file) if input_analoglibrarysearch is not None: molecular_network_filtering_library.add_library_search_results_to_graph( G, input_analoglibrarysearch, annotation_prefix="Analog:") nx.write_graphml(G, output_graphml, infer_numeric_types=True)