<commit_before>/*
 * Copyright 2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package com.antigenomics.vdjdb

import com.antigenomics.vdjdb.stat.ClonotypeSearchSearchSummary
import com.antigenomics.vdjdb.stat.Counter
import com.antigenomics.vdjtools.misc.Software
import com.antigenomics.vdjtools.io.SampleWriter
import com.antigenomics.vdjtools.sample.Sample
import com.antigenomics.vdjtools.sample.SampleCollection
import com.antigenomics.vdjtools.sample.metadata.MetadataTable
import com.antigenomics.vdjtools.misc.ExecUtil

if (args.length > 0 && args[0].toLowerCase() == "update") {
    Util.checkDatabase(true)
    System.exit(0)
}

def DEFAULT_PARAMETERS = "2,1,1,2", DEFAULT_CONFIDENCE_THRESHOLD = "2",
    ALLOWED_SPECIES_ALIAS = ["human": "homosapiens", "mouse": "musmusculus",
                             "rat"  : "rattusnorvegicus", "monkey": "macacamulatta"],
    ALLOWED_GENES = ["TRA", "TRB"]

def cli = new CliBuilder(usage: "vdjdb [options] " +
        "[sample1 sample2 sample3 ... if -m is not specified] output_prefix\n" +
        "Input samples should be provided in VDJtools format. See VDJtools/Convert utility.")
cli.h("display help message")
cli.m(longOpt: "metadata", argName: "filename", args: 1,
        "Metadata file. First and second columns should contain file name and sample id. " +
                "Header is mandatory and will be used to assign column names for metadata.")
cli._(longOpt: "search-params", argName: "s,i,d,t", args: 1,
        "CDR3 sequence search parameters: " +
                "allowed number of substitutions (s), insertions (i), deletions (d) and total number of mutations. " +
                "[default=$DEFAULT_PARAMETERS]")
cli._(longOpt: "database", argName: "string", args: 1, "Path and prefix of an external database. " +
        "The prefix should point to a '.txt' file (database itself) and '.meta.txt' (database column metadata).")
cli._(longOpt: "use-fat-db", "Use a more redundant database version, with extra fields (meta, method, etc). " +
        "Fat database can contain several records for a TCR:pMHC pair corresponding to different replicates/tissue sources/targets.")
//cli._(longOpt: "summary", argName: "col1,col2,...", args: 1,
//        "Table columns for summarizing, e.g. origin,disease.type,disease,source for default database.")
cli._(longOpt: "filter", argName: "logical expression(__field__,...)", args: 1,
        "Logical filter evaluated for database columns. Supports Regex, .contains(), .startsWith(), etc.")
cli.S(longOpt: "species", argName: "name", args: 1, required: true,
        "Species of input sample(s), allowed values: ${ALLOWED_SPECIES_ALIAS.keySet()}.")
cli._(longOpt: "software", argName: "string", required: true, args: 1,
        "Input RepSeq data format. Currently supported: ${Software.values().join(", ")}. Default is VDJtools format.")
cli.R(longOpt: "gene", argName: "name", args: 1, required: true,
        "Receptor gene of input sample(s), allowed values: $ALLOWED_GENES.")<commit_msg>Make software arg optional<commit_after>/*
 * Copyright 2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package com.antigenomics.vdjdb

import com.antigenomics.vdjdb.stat.ClonotypeSearchSearchSummary
import com.antigenomics.vdjdb.stat.Counter
import com.antigenomics.vdjtools.misc.Software
import com.antigenomics.vdjtools.io.SampleWriter
import com.antigenomics.vdjtools.sample.Sample
import com.antigenomics.vdjtools.sample.SampleCollection
import com.antigenomics.vdjtools.sample.metadata.MetadataTable
import com.antigenomics.vdjtools.misc.ExecUtil

if (args.length > 0 && args[0].toLowerCase() == "update") {
    Util.checkDatabase(true)
    System.exit(0)
}

def DEFAULT_PARAMETERS = "2,1,1,2", DEFAULT_CONFIDENCE_THRESHOLD = "2",
    ALLOWED_SPECIES_ALIAS = ["human": "homosapiens", "mouse": "musmusculus",
                             "rat"  : "rattusnorvegicus", "monkey": "macacamulatta"],
    ALLOWED_GENES = ["TRA", "TRB"]

def cli = new CliBuilder(usage: "vdjdb [options] " +
        "[sample1 sample2 sample3 ... if -m is not specified] output_prefix\n" +
        "Input samples should be provided in VDJtools format. See VDJtools/Convert utility.")
cli.h("display help message")
cli.m(longOpt: "metadata", argName: "filename", args: 1,
        "Metadata file. First and second columns should contain file name and sample id. " +
                "Header is mandatory and will be used to assign column names for metadata.")
cli._(longOpt: "search-params", argName: "s,i,d,t", args: 1,
        "CDR3 sequence search parameters: " +
                "allowed number of substitutions (s), insertions (i), deletions (d) and total number of mutations. " +
                "[default=$DEFAULT_PARAMETERS]")
cli._(longOpt: "database", argName: "string", args: 1, "Path and prefix of an external database. " +
        "The prefix should point to a '.txt' file (database itself) and '.meta.txt' (database column metadata).")
cli._(longOpt: "use-fat-db", "Use a more redundant database version, with extra fields (meta, method, etc). " +
        "Fat database can contain several records for a TCR:pMHC pair corresponding to different replicates/tissue sources/targets.")
//cli._(longOpt: "summary", argName: "col1,col2,...", args: 1,
//        "Table columns for summarizing, e.g. origin,disease.type,disease,source for default database.")
cli._(longOpt: "filter", argName: "logical expression(__field__,...)", args: 1,
        "Logical filter evaluated for database columns. Supports Regex, .contains(), .startsWith(), etc.")
cli.S(longOpt: "species", argName: "name", args: 1, required: true,
        "Species of input sample(s), allowed values: ${ALLOWED_SPECIES_ALIAS.keySet()}.")
cli._(longOpt: "software", argName: "string", args: 1,
        "Input RepSeq data format. Currently supported: ${Software.values().join(", ")}. Default is VDJtools format.")
cli.R(longOpt: "gene", argName: "name", args: 1, required: true,
        "Receptor gene of input sample(s), allowed values: $ALLOWED_GENES.")
{'fraction_non_alphanumeric': 0.12487611496531219, 'fraction_numerical': 0.008494973807164095, 'mean_word_length': 3.9816643159379406, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3743349', 'n_tokens_mistral': 2176, 'n_tokens_neox': 2085, 'n_words': 700}