Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser(
        description=f"""
Version:    {__version__}
Author:     Gabriele Girelli
Docs:       http://ggirelli.github.io/ifish-probe-design
Code:       http://github.com/ggirelli/ifish-probe-design

An iFISH probe design pipeline, with web interface included.
""",
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    parser.set_defaults(parse=default_parser)
    parser = ap.add_version_option(parser)

    subparsers = parser.add_subparsers(
        title="sub-commands",
        help="Access the help page for a sub-command with: sub-command -h",
    )

    scripts.dbchk.init_parser(subparsers)
    scripts.mkdb.init_parser(subparsers)
    scripts.query.query.init_parser(subparsers)
    scripts.serve.init_parser(subparsers)

    args = parser.parse_args()
    args = args.parse(args)
    args.run(args)
Ejemplo n.º 2
0
def init_parser(subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
    parser = subparsers.add_parser(
        __name__.split(".")[-1],
        description="""
Checks integrity of a database. Specifically:
- a ".config" file must be present
    * Overlapping status must match.
- At least one non-empty chromosome file
    * Appropriate format (3 columns).
    * Positions must be sorted.
    * An ODN must end after it starts.
    * No ODNs can start from the same position.
    * No ODNs can be totally included in another one.
""",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Check integrity of a database.",
    )

    parser.add_argument(
        "dbDirPath", type=str, default=".", help="""Path to database directory."""
    )
    parser = ap.add_version_option(parser)

    parser.set_defaults(parse=parse_arguments, run=run)

    return parser
Ejemplo n.º 3
0
def init_parser(
        subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
    parser = subparsers.add_parser(
        __name__.split(".")[-1],
        description="""Possible ifpd db queries.""",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Possible ifpd db queries.",
    )
    parser.set_defaults(parse=default_parser)
    parser = ap.add_version_option(parser)

    sub_subparsers = parser.add_subparsers(
        title="sub-commands",
        help="Access the help page for a sub-command with: sub-command -h",
    )

    scripts.query.probe.init_parser(sub_subparsers)
    scripts.query.set.init_parser(sub_subparsers)

    return parser
Ejemplo n.º 4
0
def init_parser(subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
    parser = subparsers.add_parser(
        __name__.split(".")[-1],
        description="""
Builds a database of complementary oligodeoxyribonucleotides (ODNs) in a format
compatible with ifpd.

DISCLAIMER: this script does NOT generate a new database. It only re-formats an
existing database to a format compatible with ifpd.

The script takes a tabulation-separated values (tsv) file with four (4) columns:
chromosome (or feature), chromStart, chromEnd, sequence. The first three (3) column are
identical to the columns of a BED3 file.

NOTE: only non-arbitrary nucleotides in standard IUPAC format are allowed in the
ODNs sequence. https://www.bioinformatics.org/sms/iupac.html

After the database is created, we advise running the ifpd dbchk script to
test its integrity.

Details on the BED3 format are available on the UCSC website:
https://genome.ucsc.edu/FAQ/FAQformat.html#format1
""",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Builds a database of complementary ODNs compatible with FISH-ProDe.",
    )

    parser.add_argument(
        "input",
        metavar="input",
        type=str,
        help="""Path to input file. Four (4) tabulation-separated columns are expected:
        chromosome, chromStart, chromEnd, and sequence.""",
    )
    parser.add_argument("dbName", metavar="dbName", type=str, help="Database name.")

    parser.add_argument(
        "--output",
        metavar="dirPath",
        type=str,
        default=".",
        help="""Path to directory where to build the database. Created if missing.
            Defaults a subfolder of current directory with database name.""",
    )
    parser.add_argument(
        "--refGenome",
        metavar="refGen",
        type=str,
        default="",
        help="Reference genome. Only stored in the config file.",
    )
    parser = ap.add_version_option(parser)

    advanced = parser.add_argument_group("advanced arguments")
    advanced.add_argument(
        "--increment-chrom-end",
        action="store_const",
        dest="incrementChromEnd",
        const=True,
        default=False,
        help="""Use this option if your input bed file is not in UCSC bed format,
            and the last position (chromEnd) is actually included. This forces
            a unit increase of that position to convert to UCSC bed format.""",
    )
    advanced.add_argument(
        "--custom-config",
        metavar="config",
        type=str,
        nargs="*",
        help="""Space separated "key:value" pairs to store in the
        database .config file. No quotes needed.""",
    )
    advanced.add_argument(
        "-f",
        action="store_const",
        dest="forceRun",
        const=True,
        default=False,
        help="""Force overwriting of the database if already run.
            !!!This is potentially dangerous!!!""",
    )

    parser.set_defaults(parse=parse_arguments, run=run)

    return parser
Ejemplo n.º 5
0
def init_parser(subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
    parser = subparsers.add_parser(
        __name__.split(".")[-1],
        description="""
Design a FISH probe set in a genomic region, with the aim of having the probes
as homogeneously spaced as possible. Concisely, the script does the following:
- Identify all probe candidates
- Calculate centrality, size, and homogeneity for each candidate
- Build a set of consecutive (nProbes+1) windows of the same size
    + Shift the windows set to build additional windows sets. Each windows set
      will produce one probe set candidate.
- For each window set:
    + Find the best probe in each window.
    + Aggregate each window's best probe into a candidate probe set.
- Rank candidate probe sets based on probe homogeneity.
- Return the top N candidates (maxSets), with plots, tables, fasta and bed.
""",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Design a FISH probe set in a genomic region.",
    )
    parser.add_argument(
        "database", metavar="database", type=str, help="Path to database folder."
    )

    parser.add_argument(
        "chrom",
        type=str,
        help="Database feature to query for a probe set.",
    )
    parser.add_argument(
        "outdir",
        metavar="outDir",
        type=str,
        help="Path to query output directory. Stops if it exists already.",
    )
    parser.add_argument(
        "nProbes", metavar="nProbes", type=int, help="Number of probes to design."
    )

    parser.add_argument(
        "--region",
        type=int,
        nargs=2,
        default=(0, np.inf),
        help="""Start and end locations (space-separated) of the region of interest.
        When a region is not provided (or start/end coincide),
        the whole feature is queried.""",
    )
    parser.add_argument(
        "--n-oligo",
        metavar="nOligo",
        type=int,
        default=48,
        help="Number of oligos per probe. Default: 48",
    )
    parser.add_argument(
        "--max-sets",
        metavar="maxProbes",
        type=int,
        default=-1,
        help="""Maximum number of probe set candidates to output.
            Set to -1 to retrieve all candidates. Default: -1""",
    )
    parser = ap.add_version_option(parser)

    advanced = parser.add_argument_group("advanced arguments")
    advanced.add_argument(
        "--order",
        metavar="feature",
        type=str,
        default=const.featureList,
        nargs="+",
        help="""Space-separated features, used as explained in script description.
        The available features are: 'centrality', 'size', and 'homogeneity'. At least 2
        features must be listed. Default: "size homogeneity centrality".""",
    )
    advanced.add_argument(
        "--filter-thr",
        metavar="filterThr",
        type=float,
        default=0.1,
        help="""Threshold of first feature filter, used to identify
        a range around the best value (percentage range around it). Accepts values
        from 0 to 1. Default: 0.1""",
    )
    advanced.add_argument(
        "--min-d",
        metavar="minD",
        type=int,
        default=0,
        help="*DEPRECATED* Minimum distance between consecutive oligos. Default: 1",
    )
    advanced.add_argument(
        "--exact-n-oligo",
        action="store_const",
        dest="exact_n_oligo",
        const=True,
        default=False,
        help="""Stop if not enough oligos are found,
        instead of designing the largest probe.""",
    )
    advanced.add_argument(
        "--window-shift",
        metavar="winShift",
        type=float,
        default=0.1,
        help="""Window fraction for windows shifting.""",
    )
    advanced.add_argument(
        "-t",
        "--threads",
        metavar="nthreads",
        type=int,
        help="""Number of threads for parallelization. Default: 1""",
        default=1,
    )
    advanced.add_argument(
        "-f",
        action="store_const",
        dest="forceRun",
        const=True,
        default=False,
        help="""Force overwriting of the query if already run.
            This is potentially dangerous.""",
    )

    parser.set_defaults(parse=parse_arguments, run=run)

    return parser
Ejemplo n.º 6
0
def init_parser(
        subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
    parser = subparsers.add_parser(
        __name__.split(".")[-1],
        description="""
Design a FISH probe in a genomic region of interest using a database of
oligonucleotides. Concisely, the script does the following:
- Identify all probe candidates
- Calculate centrality, size, and homogeneity for each candidate
- Identify the candidate with the best first feature (featOrder), i.e.,
  max(centrality), min(size), or max(homogeneity).
- Build a range around the best first feature value (filterThr) and filter out
  all the candidates that do not fall in it.
- Rank the remaining candidates based on the second feature (featOrder), i.e.,
  decreasing for centrality, increasing for size or homogeneity.
- Return the top N candidates (maxProbes), with plots, tables, fasta and bed.
""",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Design a FISH probe in a genomic region of interest.",
    )

    parser.add_argument("database",
                        metavar="database",
                        type=str,
                        help="Path to database folder.")
    parser.add_argument(
        "chrom",
        type=str,
        help="Database feature to query for a probe.",
    )
    parser.add_argument(
        "outdir",
        metavar="outDir",
        type=str,
        help="Path to query output directory. Stops if it exists already.",
    )

    parser.add_argument(
        "--region",
        metavar=("chromStart", "chromEnd"),
        type=int,
        nargs=2,
        default=(0, np.inf),
        help=
        """Start and end locations (space-separated) of the region of interest.
        When a region is not provided (or start/end coincide),
        the whole feature is queried.""",
    )
    parser.add_argument(
        "--n-oligo",
        metavar="nOligo",
        type=int,
        default=48,
        help=
        """Number of oligos per probe. If not enough oligos are found, the largest
        probe (with greater number of oligos) is designed by default. Default: 48""",
    )
    parser.add_argument(
        "--max-probes",
        metavar="nProbes",
        type=int,
        default=-1,
        help="""Maximum number of probe candidates to output.
            Set to -1 to retrieve all candidates. Default: -1""",
    )

    parser = ap.add_version_option(parser)

    advanced = parser.add_argument_group("advanced arguments")
    advanced.add_argument(
        "--order",
        metavar="feature",
        type=str,
        default=const.featureList,
        nargs="+",
        help=
        """Space-separated features, used as explained in script description.
        The available features are: 'centrality', 'size', and 'homogeneity'. At least 2
        features must be listed. Default: "size homogeneity centrality".""",
    )
    advanced.add_argument(
        "--filter-thr",
        metavar="filterThr",
        type=float,
        default=0.1,
        help="""Threshold of first feature filter, used to identify
        a range around the best value (percentage range around it). Accepts values
        from 0 to 1. Default: 0.1""",
    )
    advanced.add_argument(
        "--min-d",
        metavar="minD",
        type=int,
        default=10,
        help=
        "*DEPRECATED* Minimum distance between consecutive oligos. Default: 10",
    )
    advanced.add_argument(
        "--exact-n-oligo",
        action="store_const",
        dest="exact_n_oligo",
        const=True,
        default=False,
        help="""Stop if not enough oligos are found,
        instead of designing the largest probe.""",
    )
    advanced.add_argument(
        "-f",
        action="store_const",
        dest="forceRun",
        const=True,
        default=False,
        help="""Force overwriting of the query if already run.
            !!!This is potentially dangerous!!!""",
    )

    parser.set_defaults(parse=parse_arguments, run=run)

    return parser
Ejemplo n.º 7
0
def init_parser(
        subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
    parser = subparsers.add_parser(
        __name__.split(".")[-1],
        description="Run WebServer.",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Run WebServer.",
    )
    parser.add_argument(
        "static",
        metavar="folder",
        type=str,
        help="Path to static folder (created if not found).",
    )

    parser.add_argument(
        "-u",
        "--url",
        metavar="url",
        type=str,
        default="0.0.0.0",
        help="URL hosting the web server. Default: 0.0.0.0",
    )
    parser.add_argument(
        "-p",
        "--port",
        metavar="port",
        type=int,
        default=8080,
        help="Web server port. Default: 8080",
    )
    parser.add_argument(
        "-m",
        "--mail",
        metavar="email",
        type=str,
        default="*****@*****.**",
        help="Email address of server admin.",
    )
    parser = ap.add_version_option(parser)

    advanced = parser.add_argument_group("advanced arguments")
    advanced.add_argument(
        "--hide-breadcrumbs",
        action="store_const",
        dest="show_breadcrumbs",
        const=False,
        default=True,
        help="""Hide navigation breadcrumbs.""",
    )
    advanced.add_argument(
        "-R",
        "--custom-routes",
        metavar="routesFile",
        type=str,
        help="Path to custom routes Python file.",
    )
    parser.add_argument(
        "-T",
        "--custom-templates",
        metavar="templateFolder",
        type=str,
        help="Path to folder with custom templates.",
    )
    parser.add_argument(
        "-H",
        "--homepage",
        metavar="homepageTemplate",
        type=str,
        help="""Name of homepage template. Homepage is off by default.
        Use "-H home_default" to turn default homepage template on.
        When using a custom homepage template, -T must be specified.""",
    )

    parser.set_defaults(parse=parse_arguments, run=run)

    return parser