"""remove abundances"""

usage = """

### `sourmash signature flatten` - remove abundance information from signatures

Flatten the specified signature(s), removing abundances and setting
track_abundance to False.

For example,

sourmash signature flatten *.sig -o flattened.sig

will remove all abundances from all of the .sig files in the current
directory.

The `flatten` command accepts the same selectors as `extract`.

"""

from sourmash.cli.utils import add_moltype_args, add_ksize_arg, add_picklist_args


def subparser(subparsers):
    subparser = subparsers.add_parser("flatten", description=__doc__, usage=usage)
    subparser.add_argument("signatures", nargs="*")
    subparser.add_argument(
        "-q", "--quiet", action="store_true", help="suppress non-error output"
    )
    subparser.add_argument(
        "-o",
        "--output",
        metavar="FILE",
        help="output signature to this file (default stdout)",
        default="-",
    )
    subparser.add_argument(
        "--md5",
        default=None,
        help="select signatures whose md5 contains this substring",
    )
    subparser.add_argument(
        "--name",
        default=None,
        help="select signatures whose name contains this substring",
    )
    subparser.add_argument(
        "-f", "--force", action="store_true", help="try to load all files as signatures"
    )
    subparser.add_argument(
        "--from-file",
        help="a text file containing a list of files to load signatures from",
    )
    add_ksize_arg(subparser)
    add_moltype_args(subparser)
    add_picklist_args(subparser)


def main(args):
    import sourmash

    return sourmash.sig.__main__.flatten(args)
