Search in sources :

Example 1 with JCommanderBasedMain

use of com.milaboratory.cli.JCommanderBasedMain in project repseqio by repseqio.

the class Main method main.

public static void main(String[] args) throws Exception {
    Signal.handle(new Signal("PIPE"), new SignalHandler() {

        @Override
        public void handle(Signal signal) {
            System.exit(0);
        }
    });
    if (System.getProperty("localOnly") == null) {
        Path cachePath = Paths.get(System.getProperty("user.home"), ".repseqio", "cache");
        SequenceResolvers.initDefaultResolver(cachePath);
    }
    // Setting up main helper
    JCommanderBasedMain main = new JCommanderBasedMain("repseqio", new ListAction(), new FilterAction(), new MergeAction(), new CompileAction(), new GenerateClonesAction(), new NormalizeCloneAbundancesAction(), new ExportCloneSequencesAction(), new FastaAction(), new TsvAction(), new InferAnchorPointsAction(), new DebugAction(), new FormatAction(), new StatAction(), new FromFastaAction(), new FromPaddedFastaAction());
    main.setVersionInfoCallback(new Runnable() {

        @Override
        public void run() {
            VersionInfo milib = VersionInfo.getVersionInfoForArtifact("milib");
            VersionInfo repseqio = VersionInfo.getVersionInfoForArtifact("repseqio");
            StringBuilder builder = new StringBuilder();
            builder.append("RepSeq.IO.CLI v").append(repseqio.getVersion()).append(" (built ").append(repseqio.getTimestamp()).append("; rev=").append(repseqio.getRevision()).append("; branch=").append(repseqio.getBranch()).append("; host=").append(repseqio.getHost()).append(")").append("\n");
            builder.append("MiLib v").append(milib.getVersion()).append(" (rev=").append(milib.getRevision()).append("; branch=").append(milib.getBranch()).append(")").append("\n");
            builder.append("Built-in libraries:\n");
            VDJCLibraryRegistry reg = VDJCLibraryRegistry.createDefaultRegistry();
            reg.loadAllLibraries("default");
            for (VDJCLibrary lib : reg.getLoadedLibraries()) builder.append(lib.getLibraryId()).append("\n");
            System.out.print(builder.toString());
        }
    });
    main.main(args);
}
Also used : Signal(sun.misc.Signal) Path(java.nio.file.Path) VersionInfo(com.milaboratory.util.VersionInfo) JCommanderBasedMain(com.milaboratory.cli.JCommanderBasedMain) SignalHandler(sun.misc.SignalHandler) VDJCLibrary(io.repseq.core.VDJCLibrary) VDJCLibraryRegistry(io.repseq.core.VDJCLibraryRegistry)

Example 2 with JCommanderBasedMain

use of com.milaboratory.cli.JCommanderBasedMain in project mixcr by milaboratory.

the class Main method main.

public static void main(String... args) throws Exception {
    // Getting command string if executed from script
    String command = System.getProperty("mixcr.command", "java -jar mixcr.jar");
    if (!initialized) {
        // Checking whether we are running a snapshot version
        if (VersionInfo.getVersionInfoForArtifact("mixcr").getVersion().contains("SNAPSHOT"))
            // If so, enable asserts
            ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
        TempFileManager.setPrefix("mixcr_");
        Path cachePath = Paths.get(System.getProperty("user.home"), ".mixcr", "cache");
        // if (System.getProperty("allow.http") != null || System.getenv("MIXCR_ALLOW_HTTP") != null)
        // TODO add mechanism to deny http requests
        SequenceResolvers.initDefaultResolver(cachePath);
        Path libraries = Paths.get(System.getProperty("user.home"), ".mixcr", "libraries");
        VDJCLibraryRegistry.getDefault().addPathResolverWithPartialSearch(".");
        if (System.getProperty("mixcr.path") != null) {
            Path bin = Paths.get(System.getProperty("mixcr.path"));
            Path searchPath = bin.resolve("libraries");
            if (Files.exists(searchPath))
                VDJCLibraryRegistry.getDefault().addPathResolverWithPartialSearch(searchPath);
        }
        if (System.getProperty("library.path") != null)
            VDJCLibraryRegistry.getDefault().addPathResolverWithPartialSearch(System.getProperty("library.path"));
        if (System.getenv("MIXCR_LIBRARY_PATH") != null)
            VDJCLibraryRegistry.getDefault().addPathResolverWithPartialSearch(System.getenv("MIXCR_LIBRARY_PATH"));
        if (Files.exists(libraries))
            VDJCLibraryRegistry.getDefault().addPathResolverWithPartialSearch(libraries);
        initialized = true;
    }
    // Setting up main helper
    JCommanderBasedMain main = new JCommanderBasedMain(command, new ActionAlign(), new ActionExportAlignments(), new ActionAssemble(), new ActionExportClones(), new ActionExportAlignmentsPretty(), new ActionExportClonesPretty(), new ActionAlignmentsStat(), new ActionMergeAlignments(), new ActionInfo(), new ActionExportCloneReads(), new VersionInfoAction(), new ActionAlignmentsDiff(), new ActionAssemblePartialAlignments(), new ActionAssembleContigs(), new ActionExportReads(), new ActionClonesDiff(), new ActionFilterAlignments(), new ActionListLibraries(), new ActionExtend(), new ActionSortAlignments(), new ActionSlice());
    // Adding version info callback
    main.setVersionInfoCallback(new Runnable() {

        @Override
        public void run() {
            printVersion(false);
        }
    }, new Runnable() {

        @Override
        public void run() {
            printVersion(true);
        }
    });
    // Deprecation
    if (args.length > 0 && args[0].equals("extendAlignments")) {
        System.out.println("WARNING: `extendAlignments` action is deprecated, please use `extend`");
        args[0] = "extend";
    }
    // Executing main method
    JCommanderBasedMain.ProcessResult processResult = main.main(args);
    // If something was wrong, exit with code 1
    if (processResult == JCommanderBasedMain.ProcessResult.Error)
        System.exit(1);
}
Also used : Path(java.nio.file.Path) JCommanderBasedMain(com.milaboratory.cli.JCommanderBasedMain)

Aggregations

JCommanderBasedMain (com.milaboratory.cli.JCommanderBasedMain)2 Path (java.nio.file.Path)2 VersionInfo (com.milaboratory.util.VersionInfo)1 VDJCLibrary (io.repseq.core.VDJCLibrary)1 VDJCLibraryRegistry (io.repseq.core.VDJCLibraryRegistry)1 Signal (sun.misc.Signal)1 SignalHandler (sun.misc.SignalHandler)1