def entry_point(): parser = build_args_parser( prog='stats', description='Statistics on SBML file(s)', m_add_args=add_arguments ) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) # Build the list of pathways to rank pathways = [ rpPathway.from_rpSBML( infile=pathway_filename, logger=logger ) for pathway_filename in args.pathways ] # Rank pathways stats = counts(pathways) print_stats( pathways=pathways, reactions=stats['reactions'], species=stats['species'], )
def entry_point(): parser = build_args_parser( prog='rpscore', description= 'Calculate global score by combining all scores (rules, FBA, Thermo)', m_add_args=add_arguments) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) # if len(args.pathways) == 1: # if args.outfile is None or args.outfile == '': # logger.error('Option --outfile has to be set in case of single input pathway, exiting...') # exit(1) # pathways = [] # for pathway in args.pathways: # pathways.append( # rpPathway.from_rpSBML( # infile=pathway, # logger=logger # ) # ) pathway = rpPathway.from_rpSBML(infile=args.infile, logger=logger) score = predict_score( pathway=pathway, # data_train_file=args.data_train_file, # models_path=models_path, no_of_rxns_thres=args.no_of_rxns_thres) # if len(pathways) > 1: # if not os_path.exists(args.outdir): # makedirs(args.outdir) # for i in range(len(pathways)): # # Write results into the pathway # pathways[i].set_global_score( # scores[i] # ) # # Write pathway into file # pathways[i].to_rpSBML().write_to_file( # os_path.join( # args.outdir, # os_path.basename(args.pathways[i]) # ) # ) # else: # Write results into the pathway pathway.set_global_score(score) # Write pathway into file pathway.to_rpSBML().write_to_file(args.outfile)
def entry_point(): def _make_dir(filename): dirname = os_path.dirname(filename) if dirname != '' and not os_path.exists(dirname): try: os_makedirs(dirname) except OSError as exc: # Guard against race condition if exc.errno != errno_EEXIST: raise # Args. parser = build_args_parser(prog='rpfba', description='Process to Flux Balance Analysis', m_add_args=add_arguments) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) pathway = rpPathway.from_rpSBML(infile=args.pathway_file, logger=logger) # Load compounds. df_medium_base, df_medium_user = load_compounds(medium_id=args.medium_id, file_base=__MEDIUM_PATH, file_user=args.medium_file, logger=logger) results = runFBA(pathway=pathway, gem_sbml_path=args.model_file, compartment_id=args.compartment_id, biomass_rxn_id=args.biomass_rxn_id, objective_rxn_id=args.objective_rxn_id, sim_type=args.sim, fraction_coeff=args.fraction_of, merge=args.merge, ignore_orphan_species=args.ignore_orphan_species, medium_compartment_id=args.medium_compartment_id, df_medium_base=df_medium_base, df_medium_user=df_medium_user, logger=logger) if results is None: logger.info('No results written. Exiting...') else: logger.info('Writing into file...') _make_dir(args.outfile) pathway.to_rpSBML().write_to_file(args.outfile) logger.info(' |--> written in ' + args.outfile) if args.minimal_medium_file: minimal_medium = results.get('minimal_medium', pd.DataFrame()) _make_dir(args.minimal_medium_file) minimal_medium.to_csv(args.minimal_medium_file) logger.info(' |--> written in ' + args.minimal_medium_file)
def _cli(): parser = build_args_parser( prog='rpcompletion', description= 'Parse RP2 pathways to generate rpSBML collection of unique and complete (cofactors) pathways', m_add_args=add_arguments) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) check_args(args.max_subpaths_filter, args.outdir, logger) cache = rrCache(attrs=[ 'rr_reactions', 'template_reactions', 'cid_strc', 'deprecatedCompID_compid', ]) pathways = rp_completion(rp2_metnet=args.rp2_metnet, sink=args.sink, rp2paths_compounds=args.rp2paths_compounds, rp2paths_pathways=args.rp2paths_pathways, cache=cache, upper_flux_bound=int(args.upper_flux_bound), lower_flux_bound=int(args.lower_flux_bound), max_subpaths_filter=args.max_subpaths_filter, logger=logger) # WRITE OUT if not os_path.exists(args.outdir): os_mkdir(args.outdir) # Write out selected pathways for pathway in pathways: pathway.to_rpSBML().write_to_file( os_path.join(args.outdir, 'rp_' + pathway.get_id()) + '.xml') # for pathway_id, sub_pathways in pathways.items(): # for sub_pathway in sub_pathways[-args.max_subpaths_filter:]: # sub_pathway.to_rpSBML().write_to_file( # os_path.join( # args.outdir, # 'rp_'+sub_pathway.get_id() # ) + '.xml' # ) StreamHandler.terminator = "" logger.info('{color}{typo}Results are stored in {rst}'.format( color=fg('white'), typo=attr('bold'), rst=attr('reset'))) StreamHandler.terminator = "\n" logger.info('{color}{outdir}\n'.format(color=fg('grey_70'), outdir=args.outdir))
def _cli(): parser = build_args_parser( prog = 'rpthermo', description = 'Calculate score by processing thermodynamics', m_add_args = add_arguments ) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) msg = f'Parameters\n----------\n' for param in ['pH', 'ionic_strength', 'pMg']: value = getattr(args, param) msg += f'- {param}: {value}\n' logger.info( '{color}{msg}{rst}'.format( color=fg('light_cyan'), msg=msg, rst=attr('reset') ) ) ## READ PATHWAY FROM FILE pathway = rpPathway.from_rpSBML( infile=args.infile, logger=logger ) # RUN THERMO results = runThermo( pathway=pathway, ph=args.pH, ionic_strength=args.ionic_strength, pMg=args.pMg, logger=logger ) # Print results print_results(pathway, results, logger) # Write pathway into file pathway.to_rpSBML().write_to_file(args.outfile) logger.info( "{color}{typo}Written into file: {file}{rst}".format( color=fg('white'), typo=attr('bold'), rst=attr('reset'), file=args.outfile ) )
def _cli(): parser = build_args_parser( prog = 'rpextractsink', description = 'Generate the sink from a model SBML by specifying the compartment', m_add_args = add_arguments ) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) cache = rrCache(['cid_strc'], logger=logger) genSink(cache, args.input_sbml, args.output_sink, args.remove_dead_end, args.compartment_id, logger=logger)
def entry_point(): parser = build_args_parser( prog='rpreport', description= 'generates HTML pages to explore the main characteristics (thermodynamics, fluxes, number of ' 'metabolic steps, reaction rule score) of pathways predicted with RetroPath suite', m_add_args=add_arguments) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) run_report( input_dir=args.input_dir, source_path=args.source_path, output_folder=args.output_folder, dev=args.dev, verbose=args.verbose, standalone=args.standalone, )
def entry_point(): parser = build_args_parser(prog='rprank', description='Rank pathways', m_add_args=add_arguments) args = parser.parse_args() from rptools.__main__ import init logger = init(parser, args) # Build the list of pathways to rank pathways = [ rpPathway.from_rpSBML(infile=pathway_filename, logger=logger) for pathway_filename in args.pathways ] # Rank pathways sorted_pathways = rank(pathways) sorted_pathways_str = '\n'.join( args.delimiter.join(item) for item in sorted_pathways.items()) print(f'#Name{args.delimiter}Score') print(sorted_pathways_str)