forgi 2.0.0 documentation

«  forgi.utilities package   ::   Contents   ::   forgi.utilities.debug module  »

forgi.utilities.commandline_utils module

exception forgi.utilities.commandline_utils.WrongFileFormat[source]

Bases: exceptions.ValueError

Error raised if the input file has the wrong file format or the file format could not be detected.

forgi.utilities.commandline_utils.cgs_from_args(args, rna_type='any', enable_logging=True, return_filenames=False, skip_errors=False)[source]

Given an Namespace from argparse, return a list of CoarseGrainRNA objects (or BulgeGraph objects).

Parameters:
  • args – A argparse Namespace.
  • rna_type – See documentation of load_rna
  • enable_logging – In addition to loading the CoarseGrainRNA objects, call logging.basicConfig() and use args.verbose and args.debug to set the level for different loggers.
  • return_filenames – Instead of returning a list of rnas, return a tuple rnas, filenames, where filenames is a list of filenames of equal length as the returned list of CoarseGrainRNA objects and with corresponding order. If a file contains two seperate RNA molecules, the filename will thus be found twice in the list of filenames.
  • skip_errors – Boolean. Log GraphConstructionErrors and continue with the next filename instead of letting the error propagate.

Usage:

parser = get_rna_input_parser()
args = parser.parse_args()
rnas = cgs_from_args(args)
forgi.utilities.commandline_utils.get_rna_input_parser(helptext, nargs=1, rna_type='any', enable_logging=True, parser_kwargs={})[source]
forgi.utilities.commandline_utils.hide_traceback(*args, **kwds)[source]

A context manager that catches errors of the specified class and outputs only the error message before calling sys.exit(1).

forgi.utilities.commandline_utils.load_rna(filename, rna_type='any', allow_many=True, pdb_chain=None, pdb_remove_pk=True, pdb_dotbracket='', dissolve_length_one_stems=True, pdb_annotation_tool=None, pdb_allow_www_query=False)[source]
Parameters:
  • rna_type

    One of “any”, and “3d” and “pdb”

    • ”any”: Return either BulgeGraph or CoarseGrainRNA object,
      depending on the input format
    • ”only_cg”: Only accept cg-files.
    • ”3d”: Return CoarseGrainRNA objects,
      if the file contains 3D information, raise an error otherwise
    • ”pdb”: only accept pdb files
  • allow_many – If True, return a list. If False, return a single CoarseGrainRNA object or raise a WrongFileFormat, if more than one RNA is present.
  • pdb_chain – Extract the given chain from the file. Only applicable if filename corresponds to a pdb file
  • pdb_remove_pk – Detect pseudoknot-free structures from the pdb.
  • pdb_dotbracket – Only applicable, if filename corresponds to a pdb file and pdb_chain is given.
  • dissolve_length_one_stems – Ignored if input is in forgi bg/cg format.
  • pdb_annotation_tool – Use DSSR, MC-Annotate or forgi heuristic for basepair-detection in PDB/MMCIF files (None for auto-detect). Ignored for other file-types.
Retuns:

A list of RNAs or a single RNA

forgi.utilities.commandline_utils.open_for_out(*args, **kwds)[source]

From http://stackoverflow.com/a/17603000/5069869

forgi.utilities.commandline_utils.sniff_filetype(file)[source]

«  forgi.utilities package   ::   Contents   ::   forgi.utilities.debug module  »