Example usage for org.apache.commons.cli OptionBuilder hasArg

List of usage examples for org.apache.commons.cli OptionBuilder hasArg

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder hasArg.

Prototype

public static OptionBuilder hasArg(boolean hasArg) 

Source Link

Document

The next Option created will require an argument value if hasArg is true.

Usage

From source file:org.glite.authz.pap.ui.cli.policymanagement.AddPolicy.java

@SuppressWarnings("static-access")
@Override//from  w  w  w  .  j av  a2  s  .  c o  m
protected Options defineCommandOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_AFTER_RULEID_DESCRIPTION)
            .withLongOpt(OPT_AFTER_RULEID_LONG).withArgName("rule-id").create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_BEFORE_RULEID_DESCRIPTION)
            .withLongOpt(OPT_BEFORE_RULEID_LONG).withArgName("rule-id").create());
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_BOTTOM_DESCRIPTION)
            .withLongOpt(OPT_BOTTOM_LONG).create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_PAPALIAS_DESCRIPTION)
            .withLongOpt(OPT_PAPALIAS_LONG).create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_ACTIONID_DESCRIPTION)
            .withLongOpt(OPT_ACTIONID_LONG).withArgName("action-id").create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_ACTION_DESCRIPTION)
            .withLongOpt(OPT_ACTION_LONG).create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_RESOURCE_DESCRIPTION)
            .withLongOpt(OPT_RESOURCE_LONG).create());

    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_OBLIGATION_DESCRIPTION)
            .withLongOpt(OPT_OBLIGATION_LONG).create());

    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_OBLIGATION_SCOPE_DESCRIPTION)
            .withLongOpt(OPT_OBLIGATION_SCOPE_LONG).create());
    return options;
}

From source file:org.glite.authz.pap.ui.cli.policymanagement.BanAttribute.java

@SuppressWarnings("static-access")
@Override/*from  w  w w.j a  v a 2  s  . c o m*/
protected Options defineCommandOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(false).withDescription("Set the policy as public (default)")
            .withLongOpt(OPT_PUBLIC_LONG).create());
    options.addOption(
            OptionBuilder.hasArg(false).withDescription("Set the policy as private (it won't be distributed)")
                    .withLongOpt(OPT_PRIVATE_LONG).create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_ACTION_DESCRIPTION)
            .withLongOpt(OPT_ACTION_LONG).create(OPT_ACTION));
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_RESOURCE_DESCRIPTION)
            .withLongOpt(OPT_RESOURCE_LONG).create(OPT_RESOURCE));
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_PAPALIAS_DESCRIPTION)
            .withLongOpt(OPT_PAPALIAS_LONG).create());
    return options;
}

From source file:org.glite.authz.pap.ui.cli.policymanagement.ListPolicies.java

@SuppressWarnings("static-access")
@Override//from  ww  w  .j a v  a  2s.c  o m
protected Options defineCommandOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_SHOW_XACML_DESCRIPTION)
            .withLongOpt(OPT_SHOW_XACML_LONG).create());
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_SHOW_RA_IDS_DESCRIPTION)
            .withLongOpt(OPT_SHOW_IDS_LONG).create(OPT_SHOW_RA_IDS));
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_SHOW_ALL_IDS_DESCRIPTION)
            .withLongOpt(OPT_SHOW_ALL_IDS_LONG).create(OPT_SHOW_ALL_IDS));
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_ALLPAPS_DESCRIPTION)
            .withLongOpt(OPT_ALL_LONG).create());
    options.addOption(OptionBuilder.hasArgs().withDescription(OPT_PAPALIAS_DESCRIPTION)
            .withLongOpt(OPT_PAPALIAS_LONG).create());

    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_ACTION_LONG_DESCRIPTION)
            .withLongOpt(OPT_ACTION_LONG).create());

    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_RESOURCE_LONG_DESCRIPTION)
            .withLongOpt(OPT_RESOURCE_LONG).create());
    return options;
}

From source file:org.glite.authz.pap.ui.cli.policymanagement.Move.java

@SuppressWarnings("static-access")
@Override//from   ww w  .  j a v  a  2s.c  o m
protected Options defineCommandOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_AFTER_ID_DESCRIPTION)
            .withLongOpt(OPT_AFTER_ID_LONG).withArgName("id").create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_BEFORE_ID_DESCRIPTION)
            .withLongOpt(OPT_BEFORE_ID_LONG).withArgName("id").create());
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_PAPALIAS_DESCRIPTION)
            .withLongOpt(OPT_PAPALIAS_LONG).create());
    return options;
}

From source file:org.glite.authz.pap.ui.cli.policymanagement.Purge.java

@SuppressWarnings("static-access")
@Override//w  ww  . j  av  a  2 s.  c  o m
protected Options defineCommandOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_PAPALIAS_DESCRIPTION)
            .withLongOpt(OPT_PAPALIAS_LONG).create());
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_PURGE_RESOURCES_DESCRIPTION)
            .withLongOpt(OPT_PURGE_RESOURCES_LONG).create());
    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_PURGE_ACTIONS_DESCRIPTION)
            .withLongOpt(OPT_PURGE_ACTIONS_LONG).create());
    return options;
}

From source file:org.glite.authz.pap.ui.cli.policymanagement.UnBanAttribute.java

@SuppressWarnings("static-access")
@Override/*from   ww  w .  j av  a2 s.com*/
protected Options defineCommandOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_ACTION_DESCRIPTION)
            .withLongOpt(OPT_ACTION_LONG).create(OPT_ACTION));
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_RESOURCE_DESCRIPTION)
            .withLongOpt(OPT_RESOURCE_LONG).create(OPT_RESOURCE));
    options.addOption(OptionBuilder.hasArg(true).withDescription(OPT_PAPALIAS_DESCRIPTION)
            .withLongOpt(OPT_PAPALIAS_LONG).create());
    return options;
}

From source file:org.glite.authz.pap.ui.cli.samlclient.SAMLClient.java

@Override
@SuppressWarnings("static-access")
protected Options defineCommandOptions() {
    Options options = new Options();

    options.addOption(OptionBuilder.hasArg(false).withDescription(OPT_PDP_DESCRIPTION).create(OPT_PDP));

    return options;
}

From source file:org.glite.authz.pap.ui.cli.ServiceCLI.java

@SuppressWarnings("static-access")
private static Options defineGlobalOptions() {

    Options options = new Options();

    // TODO: OPT_URL and (OPT_HOST, OPT_PORT) are mutually exclusive
    // options. Use OptionGroup.
    options.addOption(OptionBuilder.hasArg(true).withLongOpt(OPT_URL_LONG)
            .withDescription("Specifies the target PAP endpoint (default: " + String.format(DEFAULT_SERVICE_URL,
                    Pap.DEFAULT_HOST, Pap.DEFAULT_PORT, Pap.DEFAULT_SERVICES_ROOT_PATH) + ").")
            .withArgName("url").create());
    options.addOption(OptionBuilder.hasArg(true).withLongOpt(OPT_HOST_LONG)
            .withDescription(OPT_HOST_DESCRIPTION).withArgName("hostname").create());
    options.addOption(OptionBuilder.hasArg(true).withLongOpt(OPT_PORT_LONG)
            .withDescription(OPT_PORT_DESCRIPTION).create(OPT_PORT));
    options.addOption(OptionBuilder.hasArg(true).withLongOpt(OPT_PROXY_LONG)
            .withDescription(OPT_PROXY_DESCRIPTION).withArgName("file").create());
    options.addOption(OptionBuilder.hasArg(true).withLongOpt(OPT_CERT_LONG)
            .withDescription(OPT_CERT_DESCRIPTION).withArgName("file").create());
    options.addOption(OptionBuilder.hasArg(true).withLongOpt(OPT_KEY_LONG).withDescription(OPT_KEY_DESCRIPTION)
            .withArgName("file").create());
    options.addOption(OptionBuilder.hasArg(false).withLongOpt(OPT_VERBOSE_LONG)
            .withDescription(OPT_VERBOSE_DESCRIPTION).create(OPT_VERBOSE));
    return options;
}

From source file:org.magdaaproject.analysis.rhizome.RhizomeAnalysis.java

private static Options createOptions() {

    Options options = new Options();

    // task type/*from  w w  w  .  j av a2  s.c o m*/
    OptionBuilder.withArgName("string");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("task to undertake");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("task"));

    // properties file path
    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the properties file");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("properties"));

    // table name
    OptionBuilder.withArgName("string");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("name of table to work with");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("table"));

    // path to input database
    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to a single input rhizome database");
    options.addOption(OptionBuilder.create("input"));

    // id of the tablet
    OptionBuilder.withArgName("string");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("id of the tablet");
    options.addOption(OptionBuilder.create("tablet"));

    // parent directory of data to import
    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the parent directory of a dataset");
    options.addOption(OptionBuilder.create("dataset"));

    // path to output file
    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to an output file");
    options.addOption(OptionBuilder.create("output"));

    return options;
}

From source file:org.mitre.ccv.CompleteCompositionVectorMain.java

@SuppressWarnings("static-access")
public static void main(String[] argv) throws Exception {

    CompleteCompositionVectorMain ccvm = new CompleteCompositionVectorMain();

    /** What we are */
    String cli_title = APPLICATION_TITLE + " [build: " + APPLICATION_BUILD
            + "]\n(C) Copyright 2007-2010, by The MITRE Corporation.";

    /** create the Options */
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("file").hasArg(true)
            .withDescription("use given file for generating ccv").create("file"));
    options.addOption(OptionBuilder.withArgName("number").hasArg(true)
            .withDescription("number of top nmers to use in calculations").create("topNmers"));
    options.addOption(OptionBuilder.withArgName("begin").hasArg(true).withDescription("initial length of tile")
            .create("begin"));
    options.addOption(OptionBuilder.withArgName("end").hasArg(true).withDescription("ending length of title")
            .create("end"));
    options.addOption(OptionBuilder.withArgName("number").hasArg(true).withDescription(
            "what name to use: 1-name(default);2-description;3-full header(might break newick-style trees)")
            .create("name"));
    options.addOption(/*w  w w .j  a v  a2s.  c o m*/
            OptionBuilder
                    .withArgName("number").hasArg(true).withDescription("what distance calculation "
                            + "to use: 1-euclidian;2-cosine(default);" + "3-ESDistance;4-Jaccard")
                    .create("distance"));
    options.addOption(OptionBuilder.withArgName("upgma").hasArg(false)
            .withDescription("Generate UPGMA tree (default is neighor-joined)").create("upgma"));

    options.addOption(OptionBuilder.withArgName("file").hasArg(true)
            .withDescription("Do affinity propagation and write cluster values to given file name")
            .create("cluster"));
    options.addOption(OptionBuilder.withArgName("file").hasArg(true)
            .withDescription("File to write entropies to").create("entfile"));

    options.addOption(OptionBuilder.withArgName("file").hasArg(true)
            .withDescription("File to write distance matrix to").create("distfile"));

    options.addOption(OptionBuilder.hasArg(true).withArgName("file")
            .withDescription("Write tree in PhyloXML format to file").create("xml"));

    options.addOption(OptionBuilder.hasArg(true).withArgName("file")
            .withDescription("Write tree in nwk format to file").create("nwk"));

    options.addOption(OptionBuilder.hasArg(false).withDescription("Use an embedded (Derby) SQL server")
            .create("embeddedSQL"));

    options.addOption(OptionBuilder.hasArg(false)
            .withDescription("Use SQL server. Properties are defined in ccv.properties.").create("sql"));

    options.addOption(OptionBuilder.hasArg(true).withArgName("file")
            .withDescription("JSON file to write out nmers to").create("nmersfile"));

    options.addOption(OptionBuilder.hasArg(true).withArgName("file").withDescription(
            "JSON file to write out vectors to " + "(Overrides nmersout, only one file will be written).")
            .create("vectorsout"));

    options.addOption(OptionBuilder.hasArg(true).withArgName("file")
            .withDescription("JSON file to read in vectors from").create("vectorsin"));

    options.addOption(OptionBuilder.withArgName("help").hasArg(false).withDescription("Print this message")
            .create("help"));

    options.addOption(OptionBuilder.withArgName("number").hasArg(true)
            .withDescription("What preference to use: 0-min 1-median 2-avg(min,med): default is median")
            .create("prefval"));
    options.addOption(OptionBuilder.withArgName("level").hasArg(true).withDescription(
            "Set the logging (verbosity) level: OFF, FATAL, ERROR, WARN, INFO, DEBUG. TRACE, ALL (none to everything)")
            .create("verbosity"));

    // automatically generate the help statement
    HelpFormatter formatter = new HelpFormatter();

    // create the parser
    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, argv);
        if (line.getOptions().length == 0 || line.hasOption("help")) {
            System.out.println(cli_title);
            formatter.printHelp("ccv [options] -file ", options);
            return;
        }
        if (line.hasOption("verbosity")) {
            // if this fails then they get DEBUG!
            ccvm.setLoggingLevel(Level.toLevel(line.getOptionValue("verbosity")));
        }
        if (line.hasOption("file")) {
            String fileName = line.getOptionValue("file");
            BufferedReader br = new BufferedReader(new FileReader(fileName));
            ccvm.seqIter = new FastaIterator(br);
        }
        if (line.hasOption("vectorsin")) {
            ccvm.vectorsInFile = line.getOptionValue("vectorsin");
        }
        if (line.hasOption("topNmers")) {
            try {
                ccvm.topNMers = Integer.parseInt(line.getOptionValue("topNmers"));
            } catch (NumberFormatException nfe) {
                System.err.println("Error parsing topNmers option. Reason: " + nfe.getMessage());
                return;
            }
        }
        if (line.hasOption("begin")) {
            try {
                ccvm.begin = Integer.parseInt(line.getOptionValue("begin"));
            } catch (NumberFormatException nfe) {
                throw new ParseException("Error parsing 'begin' option. Reason: " + nfe.getMessage());
            }
        }
        if (line.hasOption("end")) {
            try {
                ccvm.end = Integer.parseInt(line.getOptionValue("end"));
            } catch (NumberFormatException nfe) {
                throw new ParseException("Error parsing 'end' option. Reason: " + nfe.getMessage());
            }
        }
        if (line.hasOption("name")) {
            try {
                ccvm.seqNameParser = Integer.parseInt(line.getOptionValue("name"));
            } catch (NumberFormatException nfe) {
                throw new ParseException("Error parsing 'name' option. Reason: " + nfe.getMessage());
            }
        }
        if (line.hasOption("distance")) {
            try {
                ccvm.distCalc = Integer.parseInt(line.getOptionValue("distance"));
            } catch (NumberFormatException nfe) {
                throw new ParseException("Error parsing 'distance' option. Reason: " + nfe.getMessage());
            }
        }
        if (line.hasOption("upgma")) {
            ccvm.upgma = true;
        }
        if (line.hasOption("cluster")) {
            ccvm.apClusterOutfile = line.getOptionValue("cluster");
        }
        if (line.hasOption("distfile")) {
            ccvm.matrixOutFile = line.getOptionValue("distfile");
        }
        if (line.hasOption("xml")) {
            ccvm.xmlOutFile = line.getOptionValue("xml");
        }
        if (line.hasOption("nwk")) {
            ccvm.nwkOutFile = line.getOptionValue("nwk");
        }
        if (line.hasOption("embeddedSQL")) {
            ccvm.embeddedSQL = true;
        }
        if (line.hasOption("sql")) {
            ccvm.useSQL = true;
        }
        if (line.hasOption("entfile")) {
            ccvm.entOutFile = line.getOptionValue("entfile");
        }

        /** 
         * This is done inside creatDistanceMatrix.
         * The order of nmers and vectors is important!
         */
        if (line.hasOption("nmersfile")) {
            ccvm.nmersOutFile = line.getOptionValue("nmersfile");
        }
        if (line.hasOption("vectorsout")) {
            ccvm.vectorsOutFile = line.getOptionValue("vectorsout");
            ccvm.nmersOutFile = null;
        }

        if (line.hasOption("prefval")) {
            try {
                ccvm.prefVal = Integer.parseInt(line.getOptionValue("prefval"));
            } catch (NumberFormatException nfe) {
                throw new ParseException("Error parsing 'prefval' option. Reason: " + nfe.getMessage());
            }
        }

    } catch (ParseException exp) {
        // oops, something went wrong
        System.out.println(cli_title);
        System.out.println("Invalid option!  Reason: " + exp.getMessage());
        formatter.printHelp("ccv [options] -file ", options);
        return;
    }

    /** Print out who we are */
    LOG.info(cli_title);

    VectorSet set = null;
    DistanceMatrix distMatrix = null;
    CompleteMatrix matrix = null;

    if (ccvm.vectorsInFile != null) {
        LOG.info("Reading in CompleteCompositionVectors from " + ccvm.vectorsInFile);
        // we only save the data not everything that is in the vectorSet
        BufferedReader br = new BufferedReader(new FileReader(ccvm.vectorsInFile));
        matrix = CompleteMatrix.readJsonCompleteMatrix(br);
        br.close();
        ccvm.begin = matrix.getBegin();
        ccvm.end = matrix.getEnd();
        LOG.info(String.format("Loaded in %d samples and %d nmers (features)", matrix.getNames().size(),
                matrix.getNmers().size()));

        /** just make an empty set */
        set = ccvm.generateCompleteCompositionVectorSet();

        /**
         * Need to think about this - should be able to use the nmer list
         * directly in generating the complete matrix then merge the two
         */
        if (ccvm.seqIter != null) {
            LOG.warn("Unable to process new samples when given a JSON vector set!");
        }
    } else {
        LOG.info("Generating complete composition vector set...");
        set = ccvm.generateCompleteCompositionVectorSet();

        /** If we have a sequnece iterator (i.e. a fasta file) then process those samples */
        if (ccvm.seqIter != null) {
            while (ccvm.seqIter.hasNext()) {
                Sequence s = null;
                try {
                    s = ccvm.seqIter.next();
                } catch (NoSuchElementException e) {
                    LOG.fatal("Iteration error in sequence file!", e);
                    return;
                }
                String seqString = s.seqString();
                set.addSequence(parseSequenceName(s, ccvm.seqNameParser), seqString);
            }
        }
    }

    if (!ccvm.calculateMatrix()) {
        LOG.info("No other operations left so finished!");
        return;
    }

    if (matrix == null) {
        LOG.info("Generating complete matrix of nmers...");
        try {
            matrix = set.getFullMatrix(ccvm.topNMers, ccvm.entOutFile);
        } catch (OutOfMemoryError e) {
            LOG.fatal("\nOut of memory while getting full matrix!\n"
                    + "Try limiting top nmers, increasing heap space, or "
                    + "changing the number of windows (begin/end).", e);
            return;
        }
    } // we loaded it in
    /**
     * set.getFullMatrix(matrix.getNmers)
     * and merge the two
     */

    BufferedWriter bw; // Used in several places

    /** Write out vectors or nmers before going on */
    if (ccvm.vectorsOutFile != null && ccvm.vectorsOutFile.length() != 0) {
        LOG.info(String.format("Writing %d nmers and %d vectors to file %s\n", matrix.getNmers().size(),
                matrix.getNames().size(), ccvm.vectorsOutFile));
        //matrix.writeJSONObject(matrix.writeJsonCompleteMatrix(), ccvm.vectorsOutFile);
        bw = new BufferedWriter(new FileWriter(ccvm.vectorsOutFile));
        matrix.writeJsonCompleteMatrix(bw);
        bw.close();
    } else if (ccvm.nmersOutFile != null && ccvm.nmersOutFile.length() != 0) {
        LOG.info(String.format("Writing %d nmers to file %s\n", matrix.getNmers().size(), ccvm.nmersOutFile));
        //matrix.writeJSONObject(matrix.writeJsonNmers(), ccvm.nmersOutFile);
        bw = new BufferedWriter(new FileWriter(ccvm.nmersOutFile));
        matrix.writeJsonNmers(bw);
        bw.close();
    }

    /** Build distance matrix */
    if (!ccvm.calculateDistances()) {
        LOG.info("Done generating vector matrix. No other operations left so finished!");
        return;
    }
    LOG.info("Generating distance matrix...");
    distMatrix = ccvm.createDistanceMatrix(set, matrix);

    if (ccvm.calculateTree() && set.getSampleNames().size() > 2) {
        LOG.info("Creating tree");

        Tree tree = ccvm.createTree(distMatrix);
        if (ccvm.nwkOutFile != null) {
            try {
                bw = new BufferedWriter(new FileWriter(ccvm.nwkOutFile));
                ccvm.writeNwkTree(tree, bw);
                bw.close();
            } catch (Exception ioe) {
                LOG.error(String.format("Error in writing tree to newick file '%s'!", ccvm.nwkOutFile), ioe);
            }
        }

        /** We can output both */
        if (ccvm.xmlOutFile != null) {
            try {
                bw = new BufferedWriter(new FileWriter(ccvm.xmlOutFile));
                ccvm.writePhyloXMLTree(tree, bw);
                bw.close();
            } catch (IOException ioe) {
                LOG.error(String.format("Error in writing tree to phyloXML file '%s'!", ccvm.xmlOutFile), ioe);
            }
        }
    } else if (ccvm.calculateTree() && set.getSampleNames().size() <= 2) {
        LOG.error("Cannot build a tree with less than 3 samples!");
    }

    if (ccvm.matrixOutFile != null) {
        LOG.info("Writing distance matrix to file.");
        try {
            ccvm.writeDistanceMatrix(distMatrix, new BufferedWriter(new FileWriter(ccvm.matrixOutFile)));
        } catch (IOException ioe) {
            LOG.error(String.format("Error in writing distances to file '%s'!", ccvm.matrixOutFile), ioe);
        }
    }

    /** 
     * Run AP Clustering 
     * 
     * Cluster file format: sample_name(String)<tab>cluster_id(Integer)
     */
    if (ccvm.apClusterOutfile != null) {
        LOG.info("Running affinity propagation clustering...");
        AffinityPropagation ap = ccvm.cluster(distMatrix, ccvm.prefVal);
        int[] clusters = ap.getClusters();
        try {
            bw = new BufferedWriter(new FileWriter(ccvm.apClusterOutfile));
            for (int c = 0; c < clusters.length; c++) {
                //String id = distMatrix.getIdentifier(c).getName();
                String id = distMatrix.getIdentifier(c);
                bw.write(id + "\t" + Integer.toString(clusters[c]) + "\n");

            }
            bw.close();
        } catch (IOException ioe) {
            LOG.error(String.format("Error in writing clustering results to the file '%s'!",
                    ccvm.apClusterOutfile), ioe);
        }
    }
    LOG.info("Finished!");
}