Search in sources :

Example 1 with Console

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.Console in project clusterMaker2 by RBVI.

the class CyActivator method start.

public void start(BundleContext bc) {
    // See if we have a graphics console or not
    boolean haveGUI = true;
    CySwingApplication swingAppRef = getService(bc, CySwingApplication.class);
    if (swingAppRef == null) {
        // if haveGUI is false, we don't want to provide any hooks to the treeview
        haveGUI = false;
    }
    CyApplicationManager appRef = getService(bc, CyApplicationManager.class);
    CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    CyGroupManager groupManager = getService(bc, CyGroupManager.class);
    CyGroupFactory groupFactory = getService(bc, CyGroupFactory.class);
    CyTableFactory tableFactory = getService(bc, CyTableFactory.class);
    CyTableManager tableManager = getService(bc, CyTableManager.class);
    // Create our context object.  This will probably keep track of all of the
    // registered clustering algorithms, settings, etc.
    ClusterManagerImpl clusterManager = new ClusterManagerImpl(appRef, serviceRegistrar, groupFactory, groupManager, tableFactory, tableManager);
    registerServiceListener(bc, clusterManager, "addClusterAlgorithm", "removeClusterAlgorithm", ClusterTaskFactory.class);
    registerServiceListener(bc, clusterManager, "addClusterVisualizer", "removeClusterVisualizer", ClusterVizFactory.class);
    registerServiceListener(bc, clusterManager, "addRankingAlgorithm", "removeRankingAlgorithm", RankFactory.class);
    // Register each of our algorithms
    // Attribute clusterers
    registerService(bc, new AttributeClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new AutoSOMETaskFactory(clusterManager, true), ClusterTaskFactory.class, new Properties());
    registerService(bc, new FeatureVectorTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new HierarchicalTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new KMeansTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new KMedoidTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new HopachPAMTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new PAMTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // FIXME: FFT is seriously broken!
    registerService(bc, new FFTTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new DBSCANTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    /*
		 * Hold off on these until we get improve the performance sufficiently
		 * to allow them to be useful
		 */
    // registerService(bc, new BicFinderTaskFactory(clusterManager),
    // ClusterTaskFactory.class, new Properties());
    // registerService(bc, new BiMineTaskFactory(clusterManager),
    // ClusterTaskFactory.class, new Properties());
    registerService(bc, new ChengChurchTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // Network clusterers
    registerService(bc, new NetworkClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new APClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new AutoSOMETaskFactory(clusterManager, false), ClusterTaskFactory.class, new Properties());
    registerService(bc, new FuzzifierTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new GLayClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new ConnectedComponentsTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new FCMClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new MCLClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new MCODEClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new SCPSClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new TransClustClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // Cluster ranking
    registerService(bc, new MAATaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new MAMTaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new PRWPTaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new PRTaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new HITSTaskFactory(clusterManager), RankFactory.class, new Properties());
    // Filters
    registerService(bc, new FilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new BestNeighborFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new CuttingEdgeFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new DensityFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new HairCutFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // registerService(bc, new UITaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // Visualizations
    registerService(bc, new NewNetworkViewFactory(clusterManager, false), ClusterVizFactory.class, new Properties());
    registerService(bc, new NewNetworkViewFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new HeatMapViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new KnnViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new BiclusterViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new TreeViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new CreateResultsPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new CreateRankingPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new DestroyResultsPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new DestroyRankingPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    // Dimensionality Reduction
    // registerService(bc, new PCAMenuTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new PCATaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new PCoATaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new tSNETaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    {
        // Link Network Selections
        LinkSelectionTaskFactory linkTaskFactory = new LinkSelectionTaskFactory(clusterManager);
        Properties linkSelectionProps = new Properties();
        linkSelectionProps.setProperty(INSERT_SEPARATOR_BEFORE, "true");
        linkSelectionProps.setProperty(PREFERRED_MENU, "Apps.clusterMaker Visualizations");
        linkSelectionProps.setProperty(TITLE, "Link selection across networks");
        linkSelectionProps.setProperty(COMMAND, "linkSelection");
        linkSelectionProps.setProperty(COMMAND_NAMESPACE, "clusterviz");
        linkSelectionProps.setProperty(ENABLE_FOR, "networkAndView");
        linkSelectionProps.setProperty(IN_MENU_BAR, "true");
        linkSelectionProps.setProperty(MENU_GRAVITY, "100.0");
        registerService(bc, linkTaskFactory, NetworkTaskFactory.class, linkSelectionProps);
    }
    {
        // UnLink Network Selections
        UnlinkSelectionTaskFactory unlinkTaskFactory = new UnlinkSelectionTaskFactory(clusterManager);
        Properties unlinkSelectionProps = new Properties();
        unlinkSelectionProps.setProperty(PREFERRED_MENU, "Apps.clusterMaker Visualizations");
        unlinkSelectionProps.setProperty(TITLE, "Unlink selection across networks");
        unlinkSelectionProps.setProperty(COMMAND, "unlinkSelection");
        unlinkSelectionProps.setProperty(COMMAND_NAMESPACE, "clusterviz");
        unlinkSelectionProps.setProperty(ENABLE_FOR, "networkAndView");
        unlinkSelectionProps.setProperty(IN_MENU_BAR, "true");
        unlinkSelectionProps.setProperty(MENU_GRAVITY, "100.0");
        registerService(bc, unlinkTaskFactory, NetworkTaskFactory.class, unlinkSelectionProps);
    }
    // Commands
    // These task factories provide useful commands that only make sense in the context of REST or
    // the command interface
    {
        TaskFactory commandTaskFactory = new CommandTaskFactory(clusterManager, "hascluster");
        Properties props = new Properties();
        props.setProperty(COMMAND_NAMESPACE, "cluster");
        props.setProperty(COMMAND, CommandTaskFactory.HASCLUSTER);
        props.setProperty(COMMAND_DESCRIPTION, "Test to see if this network has a cluster of the requested type");
        registerService(bc, commandTaskFactory, TaskFactory.class, props);
    }
    {
        TaskFactory commandTaskFactory = new CommandTaskFactory(clusterManager, "getnetworkcluster");
        Properties props = new Properties();
        props.setProperty(COMMAND_NAMESPACE, "cluster");
        props.setProperty(COMMAND, CommandTaskFactory.GETNETWORKCLUSTER);
        props.setProperty(COMMAND_DESCRIPTION, "Get a cluster network cluster result");
        registerService(bc, commandTaskFactory, TaskFactory.class, props);
    }
    {
        TaskFactory commandTaskFactory = new CommandTaskFactory(clusterManager, "getcluster");
        Properties props = new Properties();
        props.setProperty(COMMAND_NAMESPACE, "cluster");
        props.setProperty(COMMAND, CommandTaskFactory.GETCLUSTER);
        props.setProperty(COMMAND_DESCRIPTION, "Get an attribute cluster result");
        registerService(bc, commandTaskFactory, TaskFactory.class, props);
    }
}
Also used : MCODEClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCODE.MCODEClusterTaskFactory) MAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAM.MAMTaskFactory) HITSTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.HITS.HITSTaskFactory) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) BestNeighborFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory) FilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.FilterTaskFactory) DensityFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory) HairCutFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory) CuttingEdgeFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory) FCMClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.FCM.FCMClusterTaskFactory) CyGroupFactory(org.cytoscape.group.CyGroupFactory) KMedoidTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmedoid.KMedoidTaskFactory) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) HairCutFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory) PCATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pca.PCATaskFactory) HopachPAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory) FuzzifierTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.Fuzzifier.FuzzifierTaskFactory) MAATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAA.MAATaskFactory) MCLClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCL.MCLClusterTaskFactory) CuttingEdgeFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory) CyApplicationManager(org.cytoscape.application.CyApplicationManager) FFTTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.fft.FFTTaskFactory) HierarchicalTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hierarchical.HierarchicalTaskFactory) KMeansTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmeans.KMeansTaskFactory) ChengChurchTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.ChengChurch.ChengChurchTaskFactory) GLayClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.GLay.GLayClusterTaskFactory) PCoATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pcoa.PCoATaskFactory) PAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.pam.PAMTaskFactory) HopachPAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory) NetworkClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.NetworkClusterTaskFactory) Properties(java.util.Properties) FeatureVectorTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.featureVector.FeatureVectorTaskFactory) PRTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PR.PRTaskFactory) BestNeighborFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory) CyGroupManager(org.cytoscape.group.CyGroupManager) ConnectedComponentsTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.ConnectedComponents.ConnectedComponentsTaskFactory) TransClustClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.TransClustClusterTaskFactory) AutoSOMETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.autosome.AutoSOMETaskFactory) DBSCANTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.DBSCAN.DBSCANTaskFactory) AttributeClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.AttributeClusterTaskFactory) APClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.AP.APClusterTaskFactory) PRWPTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PRWP.PRWPTaskFactory) SCPSClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.SCPS.SCPSClusterTaskFactory) CommandTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.commands.CommandTaskFactory) CyTableFactory(org.cytoscape.model.CyTableFactory) edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory) CyTableManager(org.cytoscape.model.CyTableManager) DensityFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory) NetworkTaskFactory(org.cytoscape.task.NetworkTaskFactory) HITSTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.HITS.HITSTaskFactory) AutoSOMETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.autosome.AutoSOMETaskFactory) FCMClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.FCM.FCMClusterTaskFactory) KMeansTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmeans.KMeansTaskFactory) TransClustClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.TransClustClusterTaskFactory) PCAMenuTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pca.PCAMenuTaskFactory) FFTTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.fft.FFTTaskFactory) KMedoidTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmedoid.KMedoidTaskFactory) SCPSClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.SCPS.SCPSClusterTaskFactory) MCLClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCL.MCLClusterTaskFactory) NetworkClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.NetworkClusterTaskFactory) PCATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pca.PCATaskFactory) ChengChurchTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.ChengChurch.ChengChurchTaskFactory) APClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.AP.APClusterTaskFactory) edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory) DBSCANTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.DBSCAN.DBSCANTaskFactory) FeatureVectorTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.featureVector.FeatureVectorTaskFactory) HierarchicalTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hierarchical.HierarchicalTaskFactory) PAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.pam.PAMTaskFactory) BestNeighborFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory) AttributeClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.AttributeClusterTaskFactory) ConnectedComponentsTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.ConnectedComponents.ConnectedComponentsTaskFactory) PRWPTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PRWP.PRWPTaskFactory) FilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.FilterTaskFactory) ClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory) TaskFactory(org.cytoscape.work.TaskFactory) DensityFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory) HairCutFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory) NetworkTaskFactory(org.cytoscape.task.NetworkTaskFactory) MAATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAA.MAATaskFactory) FuzzifierTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.Fuzzifier.FuzzifierTaskFactory) PCoATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pcoa.PCoATaskFactory) GLayClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.GLay.GLayClusterTaskFactory) MAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAM.MAMTaskFactory) PRTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PR.PRTaskFactory) CommandTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.commands.CommandTaskFactory) HopachPAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory) MCODEClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCODE.MCODEClusterTaskFactory) CuttingEdgeFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory)

Example 2 with Console

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.Console in project clusterMaker2 by RBVI.

the class TransClust method main.

/**
 * The main method for the TransClust program. Starts the program
 * appropriately.
 * @param args The input variables.
 */
public static void main(String[] args) {
    TransClust.args = args;
    /* initialise logging */
    Logger logger = Logger.getLogger("");
    Handler[] handler = logger.getHandlers();
    for (Handler h : handler) {
        if (h instanceof ConsoleHandler) {
            h.setLevel(Level.INFO);
            h.setFormatter(new ConsoleFormatter());
            h.setFilter(new UniqueFilter());
        }
    }
    /* check if no input is given */
    if (args.length == 0) {
        log.severe("ERROR: Please define at least an input file/directory and an " + "output file for the results. Use -help for more details or see the " + "respective documentation.\n\n");
        System.out.println(ArgsUtility.createUsage().toString());
        System.exit(-1);
    }
    /* print usage */
    if ((args.length == 1) && ((args[0].trim().equalsIgnoreCase("-help")) || (args[0].trim().equalsIgnoreCase("--help")))) {
        System.out.println(ArgsUtility.createUsage().toString());
        System.exit(-1);
    } else /* start with parameters from console */
    {
        try {
            new Console(args);
        } catch (InvalidInputFileException e) {
            log.severe("ERROR: An invalid file/path name was given.");
            e.printStackTrace();
            System.exit(-1);
        } catch (ArgsParseException e) {
            log.severe(e.getMessage());
            log.severe("ERROR: please see usage details!");
            System.out.println(ArgsUtility.createUsage().toString());
        } catch (IOException e) {
        }
    }
}
Also used : ArgsParseException(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.ArgsParseException) ConsoleFormatter(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.ConsoleFormatter) InvalidInputFileException(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidInputFileException) UniqueFilter(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.UniqueFilter) Console(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.Console) FileHandler(java.util.logging.FileHandler) ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) IOException(java.io.IOException) Logger(java.util.logging.Logger) ConsoleHandler(java.util.logging.ConsoleHandler)

Example 3 with Console

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.Console in project clusterMaker2 by RBVI.

the class Console method parseArgsAndInitProgram.

/**
 * This method parses the input parameters from the console and starts the
 * program with the correct parameters and in the correct mode. At this
 * stage all input parameters are in this form: key value. Both key and
 * value contain no spaces and if the value does, then it is bounded by
 * apostrophes.
 *
 * @throws InvalidInputFileException
 * @throws ArgsParseException
 * @throws IOException
 */
private void parseArgsAndInitProgram() throws InvalidInputFileException, ArgsParseException, IOException {
    boolean inputAndOutputGiven = findAndReadConfigIfGivenAndSetMode();
    initGivenParameters();
    if (TaskConfig.gui) {
    /* start gui with previous set parameters */
    } else if (inputAndOutputGiven && !TaskConfig.gui) {
        ClusteringManagerTask manageTask = new ClusteringManagerTask();
        // run without initialising new thread.
        manageTask.run();
    } else {
        /* either input or output is missing */
        throw new ArgsParseException("Either input file/directory (-i) or output file (-o) is missing!");
    }
}
Also used : ClusteringManagerTask(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusteringManagerTask)

Example 4 with Console

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.io.Console in project clusterMaker2 by RBVI.

the class Console method findAndReadConfigIfGivenAndSetMode.

/**
 * Looks through the input variables to see if a config file is defined. If
 * so all parameters are read from this config file. If some do not exist, a
 * warning is given, but the program continues. It may be the case that
 * these parameters are unwanted or belong to an unused implementation. It
 * also looks if a mode was given and sets this, otherwise the default is
 * used.
 *
 * It also checks whether input AND output files/directories are given,
 * which is compulsory when starting with the console and not with the gui.
 *
 * @return boolean value if an input and an output file (both) are given.
 * @throws InvalidInputFileException
 *             If the given config class does not end in .conf.
 */
private boolean findAndReadConfigIfGivenAndSetMode() throws InvalidInputFileException, ArgsParseException {
    boolean input = false;
    boolean output = false;
    String configPath = TaskConfig.DEFAULTCONFIG;
    for (int i = 0; i < args.length; i++) {
        /* check whether an input file is given */
        if (args[i].trim().equals("-i")) {
            input = true;
            ++i;
        }
        if (args[i].trim().equals("-o")) {
            output = true;
            ++i;
        }
        /* check for mode parameter */
        if (args[i].trim().equals("-mode")) {
            String value = args[i + 1].trim();
            try {
                int md = Integer.parseInt(value);
                if (md == TaskConfig.GENERAL_TRAINING_MODE) {
                    TaskConfig.mode = TaskConfig.GENERAL_TRAINING_MODE;
                } else if (md == TaskConfig.CLUSTERING_MODE) {
                    TaskConfig.mode = TaskConfig.CLUSTERING_MODE;
                } else if (md == TaskConfig.COMPARISON_MODE) {
                    TaskConfig.mode = TaskConfig.COMPARISON_MODE;
                } else if (md == TaskConfig.HIERARICHAL_MODE) {
                    TaskConfig.mode = TaskConfig.HIERARICHAL_MODE;
                } else {
                    throw new ArgsParseException("The given mode is incorrect - it does not exist! " + md);
                }
            } catch (Exception e) {
                throw new ArgsParseException("The given mode is not an interger value: " + value);
            }
            ++i;
        }
        /* check for config parameter */
        if (args[i].trim().equals("-config")) {
            String value = args[i + 1].trim();
            if (value.endsWith(".conf")) {
                TaskConfig.useConfigFile = true;
                TaskConfig.inputConfigPath = value;
                configPath = value;
            } else {
                throw new InvalidInputFileException("An invalid config file was entered. The file must end with '.conf'. Please try again! Given file=" + value);
            }
            ++i;
        }
        /* check for if -cf parameter is set */
        if (args[i].trim().equals("-cf")) {
            TaskConfig.useConfigFile = Boolean.parseBoolean(args[i + 1].trim());
            ++i;
        }
    }
    if (TaskConfig.useConfigFile) {
        try {
            FileInputStream s = new FileInputStream(configPath);
            PropertyResourceBundle configrb = new PropertyResourceBundle(s);
            // log.debug("Using config file " + configPath);
            TaskConfig.initFromConfigFile(configrb);
            FORCEnDLayoutConfig.initFromConfigFile(configrb);
            GeometricClusteringConfig.initSLCFromConfigFile(configrb);
            GeometricClusteringConfig.initKmeansFromConfigFile(configrb);
        } catch (MissingResourceException ex) {
            TaskConfig.monitor.showMessage(TaskMonitor.Level.ERROR, "WARNING: Resources are missing in the given config file: " + TaskConfig.DEFAULTCONFIG + ", key=" + ex.getKey() + ". Either you have defined these parameters in the input, or the default values are used from the " + TaskConfig.DEFAULTCONFIG + ". Or these parameters do not interest you, because they belong to an unused implemtation.");
        } catch (IOException ex) {
            TaskConfig.monitor.showMessage(TaskMonitor.Level.ERROR, "ERROR: Unable to read the given config file: " + configPath);
            System.exit(-1);
        } catch (InvalidTypeException ex) {
            TaskConfig.monitor.showMessage(TaskMonitor.Level.ERROR, "ERROR: You have perhaps given an incorrect class name of an " + "implemtation. Please note that this is case sensitive.");
            System.exit(-1);
        }
    }
    if (input && output)
        return true;
    else
        return false;
}
Also used : InvalidInputFileException(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidInputFileException) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException) InvalidInputFileException(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidInputFileException) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException) InvalidTypeException(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidTypeException) FileInputStream(java.io.FileInputStream) PropertyResourceBundle(java.util.PropertyResourceBundle) InvalidTypeException(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidTypeException)

Aggregations

InvalidInputFileException (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidInputFileException)2 AttributeClusterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.AttributeClusterTaskFactory)1 ChengChurchTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.ChengChurch.ChengChurchTaskFactory)1 DBSCANTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.DBSCAN.DBSCANTaskFactory)1 AutoSOMETaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.autosome.AutoSOMETaskFactory)1 FeatureVectorTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.featureVector.FeatureVectorTaskFactory)1 FFTTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.fft.FFTTaskFactory)1 HierarchicalTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hierarchical.HierarchicalTaskFactory)1 HopachPAMTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory)1 KMeansTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmeans.KMeansTaskFactory)1 KMedoidTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmedoid.KMedoidTaskFactory)1 PAMTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.pam.PAMTaskFactory)1 BestNeighborFilterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory)1 CuttingEdgeFilterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory)1 DensityFilterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory)1 FilterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.FilterTaskFactory)1 HairCutFilterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory)1 APClusterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.AP.APClusterTaskFactory)1 ConnectedComponentsTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.ConnectedComponents.ConnectedComponentsTaskFactory)1 FCMClusterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.FCM.FCMClusterTaskFactory)1