Exemple #1
0
        def __call__(self, parser, namespace, values, option_string=None):
            env_ksize = os.environ.get('KHMER_KSIZE', DEFAULT_K)
            env_n_tables = os.environ.get('KHMER_N_TABLES', DEFAULT_N_TABLES)
            env_tablesize = os.environ.get('KHMER_MIN_TABLESIZE',
                                           DEFAULT_MIN_TABLESIZE)

            from khmer.utils import print_error

            setattr(namespace, self.dest, values)

            if getattr(namespace, 'ksize') != env_ksize or \
               getattr(namespace, 'n_tables') != env_n_tables or \
               getattr(namespace, 'min_tablesize') != env_tablesize:
                if values:
                    print_error('''
** WARNING: You are loading a saved k-mer table from
{hashfile}, but have set k-mer table parameters.
Your values for ksize, n_tables, and tablesize
will be ignored.'''.format(hashfile=values))

            if hasattr(parser, 'hashtype'):
                info = None
                if parser.hashtype == 'hashbits':
                    info = extract_hashbits_info(
                        getattr(namespace, self.dest))
                elif parser.hashtype == 'counting':
                    info = extract_countinghash_info(
                        getattr(namespace, self.dest))
                if info:
                    K = info[0]
                    x = info[1]
                    n = info[2]
                    setattr(namespace, 'ksize', K)
                    setattr(namespace, 'n_tables', n)
                    setattr(namespace, 'min_tablesize', x)
Exemple #2
0
        def __call__(self, parser, namespace, values, option_string=None):
            env_ksize = os.environ.get('KHMER_KSIZE', DEFAULT_K)
            env_n_tables = os.environ.get('KHMER_N_TABLES', DEFAULT_N_TABLES)
            env_tablesize = os.environ.get('KHMER_MIN_TABLESIZE',
                                           DEFAULT_MIN_TABLESIZE)

            from khmer.utils import print_error

            setattr(namespace, self.dest, values)

            if getattr(namespace, 'ksize') != env_ksize or \
               getattr(namespace, 'n_tables') != env_n_tables or \
               getattr(namespace, 'min_tablesize') != env_tablesize:
                if values:
                    print_error('''
** WARNING: You are loading a saved k-mer table from
{hashfile}, but have set k-mer table parameters.
Your values for ksize, n_tables, and tablesize
will be ignored.'''.format(hashfile=values))

            if hasattr(parser, 'hashtype'):
                info = None
                if parser.hashtype == 'hashbits':
                    info = extract_hashbits_info(getattr(namespace, self.dest))
                elif parser.hashtype == 'counting':
                    info = extract_countinghash_info(
                        getattr(namespace, self.dest))
                if info:
                    K = info[0]
                    x = info[1]
                    n = info[2]
                    setattr(namespace, 'ksize', K)
                    setattr(namespace, 'n_tables', n)
                    setattr(namespace, 'min_tablesize', x)
Exemple #3
0
        def __call__(self, parser, namespace, values, option_string=None):
            setattr(namespace, self.dest, values)

            if getattr(namespace, 'ksize') != DEFAULT_K or \
               getattr(namespace, 'n_tables') != DEFAULT_N_TABLES or \
               getattr(namespace, 'max_tablesize') != DEFAULT_MAX_TABLESIZE:
                if values:
                    print_error('''
** WARNING: You are loading a saved k-mer table from
** {hashfile}, but have set k-mer table parameters.
** Your values for ksize, n_tables, and tablesize
** will be ignored.'''.format(hashfile=values))

            if hasattr(parser, 'hashtype'):
                info = None
                if parser.hashtype == 'nodegraph':
                    info = extract_hashbits_info(
                        getattr(namespace, self.dest))
                elif parser.hashtype == 'countgraph':
                    info = extract_countinghash_info(
                        getattr(namespace, self.dest))
                if info:
                    K = info[0]
                    x = info[1]
                    n = info[2]
                    setattr(namespace, 'ksize', K)
                    setattr(namespace, 'n_tables', n)
                    setattr(namespace, 'max_tablesize', x)
Exemple #4
0
        def __call__(self, parser, namespace, values, option_string=None):
            setattr(namespace, self.dest, values)

            if getattr(namespace, 'ksize') != DEFAULT_K or \
               getattr(namespace, 'n_tables') != DEFAULT_N_TABLES or \
               getattr(namespace, 'max_tablesize') != DEFAULT_MAX_TABLESIZE:
                if values:
                    print_error('''
** WARNING: You are loading a saved k-mer table from
** {hashfile}, but have set k-mer table parameters.
** Your values for ksize, n_tables, and tablesize
** will be ignored.'''.format(hashfile=values))

            if hasattr(parser, 'hashtype'):
                info = None
                if parser.hashtype == 'nodegraph':
                    info = extract_hashbits_info(
                        getattr(namespace, self.dest))
                elif parser.hashtype == 'countgraph':
                    info = extract_countinghash_info(
                        getattr(namespace, self.dest))
                if info:
                    K = info[0]
                    x = info[1]
                    n = info[2]
                    setattr(namespace, 'ksize', K)
                    setattr(namespace, 'n_tables', n)
                    setattr(namespace, 'max_tablesize', x)
Exemple #5
0
def create_countgraph(args, ksize=None, multiplier=1.0):
    if ksize is None:
        ksize = args.ksize
    if ksize > 32:
        print_error("\n** ERROR: khmer only supports k-mer sizes <= 32.\n")
        sys.exit(1)

    tablesize = _calculate_tablesize(args, 'countgraph', multiplier=multiplier)
    return khmer.CountingHash(ksize, tablesize, args.n_tables)
Exemple #6
0
def create_countgraph(args, ksize=None, multiplier=1.0):
    if ksize is None:
        ksize = args.ksize
    if ksize > 32:
        print_error("\n** ERROR: khmer only supports k-mer sizes <= 32.\n")
        sys.exit(1)

    tablesize = _calculate_tablesize(args, 'countgraph', multiplier=multiplier)
    return khmer.CountingHash(ksize, tablesize, args.n_tables)
Exemple #7
0
        def __call__(self, parser, namespace, values, option_string=None):
            env_ksize = os.environ.get("KHMER_KSIZE", DEFAULT_K)
            env_n_tables = os.environ.get("KHMER_N_TABLES", DEFAULT_N_TABLES)
            env_tablesize = os.environ.get("KHMER_MIN_TABLESIZE", DEFAULT_MIN_TABLESIZE)

            from khmer.utils import print_error

            setattr(namespace, self.dest, values)

            if (
                getattr(namespace, "ksize") != env_ksize
                or getattr(namespace, "n_tables") != env_n_tables
                or getattr(namespace, "min_tablesize") != env_tablesize
            ):
                if values:
                    print_error(
                        """
** WARNING: You are loading a saved k-mer table from
{hashfile}, but have set k-mer table parameters.
Your values for ksize, n_tables, and tablesize
will be ignored.""".format(
                            hashfile=values
                        )
                    )

            if hasattr(parser, "hashtype"):
                info = None
                if parser.hashtype == "hashbits":
                    info = extract_hashbits_info(getattr(namespace, self.dest))
                elif parser.hashtype == "counting":
                    info = extract_countinghash_info(getattr(namespace, self.dest))
                if info:
                    K = info[0]
                    x = info[1]
                    n = info[2]
                    setattr(namespace, "ksize", K)
                    setattr(namespace, "n_tables", n)
                    setattr(namespace, "min_tablesize", x)
Exemple #8
0
def report_on_config(args):
    """
        Summarizes the configuration produced by the command-line arguments
        made available by this module.
    """

    from khmer.utils import print_error

    if args.quiet:
        return

    print_error("\nPARAMETERS:")
    print_error(" - kmer size =    {0} \t\t(-k)".format(args.ksize))
    print_error(" - n hashes =     {0} \t\t(-N)".format(args.n_hashes))
    print_error(" - min hashsize = {0:5.2g} \t(-x)".format(args.min_hashsize))
    print_error("")
    print_error("Estimated memory usage is {0:.2g} bytes "
                "(n_hashes x min_hashsize)".format(args.n_hashes *
                                                   args.min_hashsize))
    print_error("-" * 8)

    if DEFAULT_MIN_HASHSIZE == args.min_hashsize:
        print_error("** WARNING: hashsize is default!  "
                    "You absodefly want to increase this!\n** "
                    "Please read the docs!")
Exemple #9
0
def report_on_config(args, hashtype='counting'):
    """Print out configuration.

    Summarize the configuration produced by the command-line arguments
    made available by this module.
    """
    from khmer.utils import print_error

    if args.quiet:
        return

    print_error("\nPARAMETERS:")
    print_error(" - kmer size =    {0} \t\t(-k)".format(args.ksize))
    print_error(" - n tables =     {0} \t\t(-N)".format(args.n_tables))
    print_error(
        " - min tablesize = {0:5.2g} \t(-x)".format(args.min_tablesize)
    )
    print_error("")
    if hashtype == 'counting':
        print_error(
            "Estimated memory usage is {0:.2g} bytes "
            "(n_tables x min_tablesize)".format(
                args.n_tables * args.min_tablesize))
    elif hashtype == 'hashbits':
        print_error(
            "Estimated memory usage is {0:.2g} bytes "
            "(n_tables x min_tablesize / 8)".format(args.n_tables *
                                                    args.min_tablesize / 8)
        )

    print_error("-" * 8)

    if DEFAULT_MIN_TABLESIZE == args.min_tablesize and \
       not hasattr(args, 'loadtable'):
        print_error(
            "** WARNING: tablesize is default!  "
            "You absodefly want to increase this!\n** "
            "Please read the docs!\n"
        )
Exemple #10
0
def report_on_config(args, hashtype='counting'):
    """
        Summarizes the configuration produced by the command-line arguments
        made available by this module.
    """

    from khmer.utils import print_error

    if args.quiet:
        return

    print_error("\nPARAMETERS:")
    print_error(" - kmer size =    {0} \t\t(-k)".format(args.ksize))
    print_error(" - n tables =     {0} \t\t(-N)".format(args.n_tables))
    print_error(" - min tablesize = {0:5.2g} \t(-x)".format(
        args.min_tablesize))
    print_error("")
    if hashtype == 'counting':
        print_error("Estimated memory usage is {0:.2g} bytes "
                    "(n_tables x min_tablesize)".format(args.n_tables *
                                                        args.min_tablesize))
    elif hashtype == 'hashbits':
        print_error("Estimated memory usage is {0:.2g} bytes "
                    "(n_tables x min_tablesize / 8)".format(
                        args.n_tables * args.min_tablesize / 8))

    print_error("-" * 8)

    if DEFAULT_MIN_TABLESIZE == args.min_tablesize and \
       not hasattr(args, 'loadtable'):
        print_error("** WARNING: tablesize is default!  "
                    "You absodefly want to increase this!\n** "
                    "Please read the docs!\n")
Exemple #11
0
def report_on_config(args, hashtype='countgraph'):
    """Print out configuration.

    Summarize the configuration produced by the command-line arguments
    made available by this module.
    """
    from khmer.utils import print_error
    if hashtype not in ('countgraph', 'nodegraph'):
        raise Exception("unknown graph type: %s" % (hashtype,))

    if args.quiet:
        return

    tablesize = _calculate_tablesize(args, hashtype)

    print_error("\nPARAMETERS:")
    print_error(" - kmer size =    {0} \t\t(-k)".format(args.ksize))
    print_error(" - n tables =     {0} \t\t(-N)".format(args.n_tables))
    print_error(
        " - max tablesize = {0:5.2g} \t(-x)".format(tablesize)
    )
    print_error("")
    if hashtype == 'countgraph':
        print_error(
            "Estimated memory usage is {0:.2g} bytes "
            "(n_tables x max_tablesize)".format(
                args.n_tables * tablesize))
    elif hashtype == 'nodegraph':
        print_error(
            "Estimated memory usage is {0:.2g} bytes "
            "(n_tables x max_tablesize / 8)".format(args.n_tables *
                                                    tablesize / 8)
        )

    print_error("-" * 8)

    if DEFAULT_MAX_TABLESIZE == tablesize and \
       not getattr(args, 'loadtable', None):
        print_error('''\

** WARNING: tablesize is default!
** You probably want to increase this with -M/--max-memory-usage!
** Please read the docs!
''')
Exemple #12
0
def report_on_config(args, hashtype='countgraph'):
    """Print out configuration.

    Summarize the configuration produced by the command-line arguments
    made available by this module.
    """
    from khmer.utils import print_error
    if hashtype not in ('countgraph', 'nodegraph'):
        raise Exception("unknown graph type: %s" % (hashtype,))

    if args.quiet:
        return

    tablesize = _calculate_tablesize(args, hashtype)

    print_error("\nPARAMETERS:")
    print_error(" - kmer size =    {0} \t\t(-k)".format(args.ksize))
    print_error(" - n tables =     {0} \t\t(-N)".format(args.n_tables))
    print_error(
        " - max tablesize = {0:5.2g} \t(-x)".format(tablesize)
    )
    print_error("")
    if hashtype == 'countgraph':
        print_error(
            "Estimated memory usage is {0:.2g} bytes "
            "(n_tables x max_tablesize)".format(
                args.n_tables * tablesize))
    elif hashtype == 'nodegraph':
        print_error(
            "Estimated memory usage is {0:.2g} bytes "
            "(n_tables x max_tablesize / 8)".format(args.n_tables *
                                                    tablesize / 8)
        )

    print_error("-" * 8)

    if DEFAULT_MAX_TABLESIZE == tablesize and \
       not getattr(args, 'loadtable', None):
        print_error('''\

** WARNING: tablesize is default!
** You probably want to increase this with -M/--max-memory-usage!
** Please read the docs!
''')
Exemple #13
0
def report_on_config( args ):
    """
        Summarizes the configuration produced by the command-line arguments 
        made available by this module.
    """

    from khmer.utils import print_error

    if args.quiet: return

    print_error( "\nPARAMETERS:" )
    print_error( " - kmer size =    {0} \t\t(-k)".format( args.ksize ) )
    print_error( " - n hashes =     {0} \t\t(-N)".format( args.n_hashes ) )
    print_error(
        " - min hashsize = {0:5.2g} \t(-x)".format( args.min_hashsize )
    )
    print_error( "" )
    print_error(
        "Estimated memory usage is {0:.2g} bytes "
        "(n_hashes x min_hashsize)".format( args.n_hashes * args.min_hashsize )
    )
    print_error( "-" * 8 )

    if DEFAULT_MIN_HASHSIZE == args.min_hashsize:
        print_error(
            "** WARNING: hashsize is default!  " 
            "You absodefly want to increase this!\n** "
            "Please read the docs!"
        )