Example usage for java.util Set addAll

List of usage examples for java.util Set addAll

Introduction

In this page you can find the example usage for java.util Set addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:Main.java

public static void main(String args[]) {
    Set set = new HashSet();
    Set set2 = new HashSet();
    StringBuffer buff1 = new StringBuffer("Irish Setter");
    StringBuffer buff2 = new StringBuffer("Irish Setter");
    set.add(buff1);/* w  ww .j  a  v a 2  s.c om*/
    set2.add(buff2);
    System.out.println(set.addAll(set2));
    System.out.println(set.addAll(set));
}

From source file:jrrombaldo.pset.PSETMain.java

public static void main(String[] args) {

    Options options = prepareOptions();//from   w  w w  .j a va  2 s.  c  o  m
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse(options, args);

        String domain = line.getOptionValue("d");

        // print help
        if (line.hasOption("h")) {
            printHelp(options);
            return;
        }

        // start gui e do nothing else
        if (!line.hasOption("c")) {
            startGuiVersion(domain);
            return;
        }

        // start gui e do nothing else
        if (!line.hasOption("d")) {
            System.out.println("a target domain is required, none was specified!");
            printHelp(options);
            return;
        }

        if (!line.hasOption("g") && !line.hasOption("b")) {
            System.out.println("No search engine selected, at least one should be present");
            printHelp(options);
            return;
        }

        if (line.hasOption("p")) {
            String proxy = line.getOptionValue("p");
            System.out.println(proxy);
        }

        Set<String> results = new HashSet<>();

        if (line.hasOption("g")) {
            results.addAll(new GoogleSearch(domain).listSubdomains());
        }

        if (line.hasOption("b")) {
            results.addAll(new BingSearch(domain).listSubdomains());
        }

        List<String> sortedResult = new ArrayList<String>(results);
        Collections.sort(sortedResult);
        int q = 1;
        for (String subDomain : sortedResult) {
            if (q == 1) {
                System.out.println("\nResults:");
            }
            System.out.println(q + ": " + subDomain);
            q++;
        }

    } catch (ParseException exp) {
        System.out.println(exp.getLocalizedMessage());
        printHelp(options);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.bright.utils.rmDuplicateLines.java

public static void main(String args) {
    File monfile = new File(args);

    Set<String> userIdSet = new LinkedHashSet<String>();

    if (monfile.isFile() && monfile.getName().endsWith(".txt")) {
        try {/*  w w  w.  j  a  va2s . co  m*/
            List<String> content = FileUtils.readLines(monfile, Charset.forName("UTF-8"));
            userIdSet.addAll(content);

            Iterator<String> itr = userIdSet.iterator();
            StringBuffer output = new StringBuffer();
            while (itr.hasNext()) {

                output.append(itr.next() + System.getProperty("line.separator"));

            }

            BufferedWriter out = new BufferedWriter(new FileWriter(monfile));
            String outText = output.toString();

            out.write(outText);

            out.close();
        } catch (IOException e) {
            e.printStackTrace();

        }
    }

}

From source file:be.vdab.util.Programma.java

public static void main(String[] args) {
    SortedSet<Voertuig> voertuigen = new TreeSet<Voertuig>();
    Datum datum = null;/* ww w.  java2s .  c  o  m*/
    Volume volumePickup = null;
    Volume volumeVrachtwagen = null;
    try {
        datum = new Datum(21, 11, 2012);
    } catch (DatumException de) {
        System.out.println(de.getMessage());
    }
    Mens bestuurder_BC = new Mens("Albert", Rijbewijs.B, Rijbewijs.C);
    Mens inzittende_A = new Mens("Karolien", Rijbewijs.A);
    Mens inzittende = new Mens("Zora");
    Mens inzittende_B = new Mens("David", Rijbewijs.B);
    Mens inzittende_DDE = new Mens("Evert", Rijbewijs.D, Rijbewijs.DE);
    Mens bestuurder_DE = new Mens("Boris", Rijbewijs.DE);
    Personenwagen wagen1Opel = new Personenwagen("Opel", datum, 250000, 4, Color.blue, bestuurder_BC,
            inzittende_A, inzittende);
    Personenwagen wagen2 = new Personenwagen("Mazda", datum, 27000, 5, Color.blue, bestuurder_BC, inzittende_A);

    try {
        volumePickup = new Volume(3, 3, 2, Maat.meter);
        volumeVrachtwagen = new Volume(3, 6, 2, Maat.meter);
    } catch (VolumeException ve) {
        System.out.println(ve.getMessage());
    }

    Pickup pickup1Opel = new Pickup("Opel", datum, 400000, 5, Color.RED, volumePickup, bestuurder_BC,
            inzittende_B, inzittende_DDE, inzittende_A);
    Pickup pickup2 = new Pickup("Toyota", datum, 39000, 4, Color.blue, volumePickup, bestuurder_BC);
    Vrachtwagen vrachtwagen1 = new Vrachtwagen("BMW", datum, 90000, 2, volumeVrachtwagen, 3000, 6,
            bestuurder_BC, inzittende_A);
    Vrachtwagen vrachtwagen2 = new Vrachtwagen("Mercedes", datum, 120000, 3, volumeVrachtwagen, 2000, 8,
            bestuurder_BC, inzittende);
    voertuigen.add(wagen1Opel); //gesorteerd op nummerplaat
    voertuigen.add(wagen2);
    voertuigen.add(pickup1Opel);
    voertuigen.add(pickup2);
    voertuigen.add(vrachtwagen1);
    voertuigen.add(vrachtwagen2);

    print(voertuigen);

    /*
    //copy manier1
    //copy (niet nodig dadelijk naar list omzetten, maar dan zit het niet in een SortedSet, oplossing: zelf copy uitvoeren, maar niet enkel referenties
    Set<Voertuig> voertuigen2=null;//=new TreeSet<Voertuig>(voertuigen); //new TreeSet<Voertuig>( org.apache.commons.collections.ComparatorUtils.reversedComparator( Voertuig.getAankoopprijsComparator()));
    //transformeren naar List, ook een copy
    List<Voertuig> lijst=new ArrayList<Voertuig>(voertuigen);//niet voertuigen 2
    //sort
      Collections.sort(lijst, org.apache.commons.collections.ComparatorUtils.reversedComparator( Voertuig.getAankoopprijsComparator()));
      print(lijst);
    */
    Set<Voertuig> voertuigen2 = new TreeSet<Voertuig>(org.apache.commons.collections.ComparatorUtils
            .reversedComparator(Voertuig.getAankoopprijsComparator()));
    voertuigen2.addAll(voertuigen);
    print(voertuigen2);

    //Copy manier 2: beter
    Set<Voertuig> voertuigen3 = new TreeSet<Voertuig>(Voertuig.getMerkComparator());
    voertuigen3.addAll(voertuigen);//deep copy of niet , staat niet in de api. Maakt het uit hier? wanneer wel?als je de vrachtwagens gaat wijzigen en je wil dat die alleen in de copy gewijzigd zijn dan deep copy nodig
    print(voertuigen3);

    try {
        schrijweg((TreeSet) voertuigen3, "wagenpark.ser");
    } catch (FileNotFoundException fnfe) {
        System.out.println(fnfe.getMessage());
    } catch (IOException ioe) {
        System.out.println(ioe.getMessage());
    }
    TreeSet<Voertuig> voertuigen4 = lees("wagenpark.ser");
    System.out.println("Voertuigen4");
    print(voertuigen4);

}

From source file:com.act.biointerpretation.l2expansion.L2FilteringDriver.java

public static void main(String[] args) throws Exception {

    // Build command line parser.
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());//from   w w w  . j ava2  s . c o m
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        LOGGER.error("Argument parsing failed: %s", e.getMessage());
        HELP_FORMATTER.printHelp(L2FilteringDriver.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    // Print help.
    if (cl.hasOption(OPTION_HELP)) {
        HELP_FORMATTER.printHelp(L2FilteringDriver.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    checkFilterOptionIsValid(OPTION_CHEMICAL_FILTER, cl);
    checkFilterOptionIsValid(OPTION_REACTION_FILTER, cl);

    // Get corpus files.
    File corpusFile = new File(cl.getOptionValue(OPTION_INPUT_CORPUS));
    if (!corpusFile.exists()) {
        LOGGER.error("Input corpus file does not exist.");
        return;
    }

    File outputFile = new File(cl.getOptionValue(OPTION_OUTPUT_PATH));
    outputFile.createNewFile();
    if (outputFile.isDirectory()) {
        LOGGER.error("Output file is directory.");
        System.exit(1);
    }

    LOGGER.info("Reading corpus from file.");
    L2PredictionCorpus predictionCorpus = L2PredictionCorpus.readPredictionsFromJsonFile(corpusFile);
    LOGGER.info("Read in corpus with %d predictions.", predictionCorpus.getCorpus().size());
    LOGGER.info("Corpus has %d distinct substrates.", predictionCorpus.getUniqueSubstrateInchis().size());

    if (cl.hasOption(OPTION_FILTER_SUBSTRATES)) {
        LOGGER.info("Filtering by substrates.");
        File substratesFile = new File(cl.getOptionValue(OPTION_FILTER_SUBSTRATES));
        L2InchiCorpus inchis = new L2InchiCorpus();
        inchis.loadCorpus(substratesFile);
        Set<String> inchiSet = new HashSet<String>();
        inchiSet.addAll(inchis.getInchiList());

        predictionCorpus = predictionCorpus
                .applyFilter(prediction -> inchiSet.containsAll(prediction.getSubstrateInchis()));

        predictionCorpus.writePredictionsToJsonFile(outputFile);
        LOGGER.info("Done writing filtered corpus to file.");
        return;
    }

    if (cl.hasOption(OPTION_SPLIT_BY_RO)) {
        LOGGER.info("Splitting corpus into distinct corpuses for each ro.");
        Map<String, L2PredictionCorpus> corpusMap = predictionCorpus
                .splitCorpus(prediction -> prediction.getProjectorName());

        for (Map.Entry<String, L2PredictionCorpus> entry : corpusMap.entrySet()) {
            String fileName = cl.getOptionValue(OPTION_OUTPUT_PATH) + "." + entry.getKey();
            File oneOutputFile = new File(fileName);
            entry.getValue().writePredictionsToJsonFile(oneOutputFile);
        }
        LOGGER.info("Done writing split corpuses to file.");
        return;
    }

    predictionCorpus = runDbLookups(cl, predictionCorpus, opts);

    LOGGER.info("Applying filters.");
    predictionCorpus = applyFilter(predictionCorpus, ALL_CHEMICALS_IN_DB, cl, OPTION_CHEMICAL_FILTER);
    predictionCorpus = applyFilter(predictionCorpus, REACTION_MATCHES_DB, cl, OPTION_REACTION_FILTER);
    LOGGER.info("Filtered corpus has %d predictions.", predictionCorpus.getCorpus().size());

    LOGGER.info("Printing final corpus.");
    predictionCorpus.writePredictionsToJsonFile(outputFile);

    LOGGER.info("L2FilteringDriver complete!.");
}

From source file:com.jivesoftware.os.routing.bird.deployable.config.extractor.ConfigExtractor.java

public static void main(String[] args) {
    String configHost = args[0];/* w w  w .  jav  a2s. c om*/
    String configPort = args[1];
    String instanceKey = args[2];
    String instanceVersion = args[3];
    String setPath = args[4];
    String getPath = args[5];

    HttpRequestHelper buildRequestHelper = buildRequestHelper(null, configHost, Integer.parseInt(configPort));

    try {
        Set<URL> packages = new HashSet<>();
        for (int i = 5; i < args.length; i++) {
            packages.addAll(ClasspathHelper.forPackage(args[i]));
        }

        Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(packages)
                .setScanners(new SubTypesScanner(), new TypesScanner()));

        Set<Class<? extends Config>> subTypesOf = reflections.getSubTypesOf(Config.class);

        File configDir = new File("./config");
        configDir.mkdirs();

        Set<Class<? extends Config>> serviceConfig = new HashSet<>();
        Set<Class<? extends Config>> healthConfig = new HashSet<>();
        for (Class<? extends Config> type : subTypesOf) {
            if (HealthCheckConfig.class.isAssignableFrom(type)) {
                healthConfig.add(type);
            } else {
                serviceConfig.add(type);
            }
        }

        Map<String, String> defaultServiceConfig = extractAndPublish(serviceConfig,
                new File(configDir, "default-service-config.properties"), "default", instanceKey,
                instanceVersion, buildRequestHelper, setPath);

        DeployableConfig getServiceOverrides = new DeployableConfig("override", instanceKey, instanceVersion,
                defaultServiceConfig);
        DeployableConfig gotSerivceConfig = buildRequestHelper.executeRequest(getServiceOverrides, getPath,
                DeployableConfig.class, null);
        if (gotSerivceConfig == null) {
            System.out.println("Failed to publish default service config for " + Arrays.deepToString(args));
        } else {
            Properties override = createKeySortedProperties();
            override.putAll(gotSerivceConfig.properties);
            override.store(new FileOutputStream("config/override-service-config.properties"), "");
        }

        Map<String, String> defaultHealthConfig = extractAndPublish(healthConfig,
                new File(configDir, "default-health-config.properties"), "default-health", instanceKey,
                instanceVersion, buildRequestHelper, setPath);

        DeployableConfig getHealthOverrides = new DeployableConfig("override-health", instanceKey,
                instanceVersion, defaultHealthConfig);
        DeployableConfig gotHealthConfig = buildRequestHelper.executeRequest(getHealthOverrides, getPath,
                DeployableConfig.class, null);
        if (gotHealthConfig == null) {
            System.out.println("Failed to publish default health config for " + Arrays.deepToString(args));
        } else {
            Properties override = createKeySortedProperties();
            override.putAll(gotHealthConfig.properties);
            override.store(new FileOutputStream("config/override-health-config.properties"), "");
        }

        Properties instanceProperties = createKeySortedProperties();
        File configFile = new File("config/instance.properties");
        if (configFile.exists()) {
            instanceProperties.load(new FileInputStream(configFile));
        }

        Properties serviceOverrideProperties = createKeySortedProperties();
        configFile = new File("config/override-service-config.properties");
        if (configFile.exists()) {
            serviceOverrideProperties.load(new FileInputStream(configFile));
        }

        Properties healthOverrideProperties = createKeySortedProperties();
        configFile = new File("config/override-health-config.properties");
        if (configFile.exists()) {
            healthOverrideProperties.load(new FileInputStream(configFile));
        }

        Properties properties = createKeySortedProperties();
        properties.putAll(defaultServiceConfig);
        properties.putAll(defaultHealthConfig);
        properties.putAll(serviceOverrideProperties);
        properties.putAll(healthOverrideProperties);
        properties.putAll(instanceProperties);
        properties.store(new FileOutputStream("config/config.properties"), "");

        System.exit(0);
    } catch (Exception x) {
        x.printStackTrace();
        System.exit(1);
    }

}

From source file:net.ontopia.topicmaps.cmdlineutils.rdbms.RDBMSIndexTool.java

public static void main(String[] argv) throws Exception {

    // Initialize logging
    CmdlineUtils.initializeLogging();//from  w  w  w.  jav  a  2 s .  co m

    // Register logging options
    CmdlineOptions options = new CmdlineOptions("RDBMSIndexTool", argv);
    CmdlineUtils.registerLoggingOptions(options);

    // Parse command line options
    try {
        options.parse();
    } catch (CmdlineOptions.OptionsException e) {
        System.err.println("Error: " + e.getMessage());
        System.exit(1);
    }

    // Get command line arguments
    String[] args = options.getArguments();

    if (args.length != 1) {
        usage();
        System.exit(3);
    }

    // load database schema project
    ClassLoader cloader = RDBMSIndexTool.class.getClassLoader();
    InputStream istream = cloader.getResourceAsStream("net/ontopia/topicmaps/impl/rdbms/config/schema.xml");
    Project dbp = DatabaseProjectReader.loadProject(istream);

    // open database connection
    String propfile = args[0];
    ConnectionFactoryIF cf = new DefaultConnectionFactory(PropertyUtils.loadProperties(new File(propfile)),
            true);

    Connection conn = cf.requestConnection();
    try {
        DatabaseMetaData dbm = conn.getMetaData();
        boolean downcase = dbm.storesLowerCaseIdentifiers();

        Map extra_indexes = new TreeMap();
        Map missing_indexes = new TreeMap();

        Iterator tables = dbp.getTables().iterator();
        while (tables.hasNext()) {
            Table table = (Table) tables.next();
            String table_name = (downcase ? table.getName().toLowerCase() : table.getName());
            //! System.out.println("T :"  + table_name);

            // get primary keys from database
            Map pkeys = getPrimaryKeys(table_name, dbm);

            // get indexes from database
            Map indexes = getIndexes(table_name, dbm);

            Map dindexes = new HashMap();
            if (table.getPrimaryKeys() != null) {
                String pkey = table_name + '(' + StringUtils.join(table.getPrimaryKeys(), ',') + ')';
                if (!pkeys.containsKey(pkey))
                    System.out.println("PKM: " + pkey);
            }

            Iterator iter = table.getIndexes().iterator();
            while (iter.hasNext()) {
                Index index = (Index) iter.next();
                String i = table_name + '(' + StringUtils.join(index.getColumns(), ',') + ')';
                String index_name = (downcase ? index.getName().toLowerCase() : index.getName());
                dindexes.put(i, index_name);
            }

            Set extra = new HashSet(indexes.keySet());
            extra.removeAll(dindexes.keySet());
            extra.removeAll(pkeys.keySet());
            if (!extra.isEmpty()) {
                Iterator i = extra.iterator();
                while (i.hasNext()) {
                    Object k = i.next();
                    extra_indexes.put(k, indexes.get(k));
                }
            }

            Set missing = new HashSet(dindexes.keySet());
            missing.addAll(pkeys.keySet());
            missing.removeAll(indexes.keySet());
            if (!missing.isEmpty()) {
                Iterator i = missing.iterator();
                while (i.hasNext()) {
                    Object k = i.next();
                    missing_indexes.put(k, dindexes.get(k));
                }
            }

        }
        if (!extra_indexes.isEmpty())
            System.out.println("/* --- Extra indexes ----------------------------------------- */");
        Iterator eiter = extra_indexes.keySet().iterator();
        while (eiter.hasNext()) {
            Object k = eiter.next();
            System.out.println("drop index " + extra_indexes.get(k) + "; /* " + k + " */");
        }

        if (!missing_indexes.isEmpty())
            System.out.println("/* --- Missing indexes---------------------------------------- */");
        Iterator miter = missing_indexes.keySet().iterator();
        while (miter.hasNext()) {
            Object k = miter.next();
            System.out.println("create index " + missing_indexes.get(k) + " on " + k + ";");
        }

    } finally {
        conn.rollback();
        conn.close();
    }

}

From source file:com.ignorelist.kassandra.steam.scraper.SharedConfig.java

public static void main(String[] args) throws IOException {
    Set<String> tags = new HashSet<>();
    for (Path p : new PathResolver().findSharedConfig()) {
        SharedConfig sharedConfig = new SharedConfig(p);
        for (Long gameId : sharedConfig.getGameIds()) {
            tags.addAll(sharedConfig.getTags(gameId));
        }//from www .j av a  2s.  c o  m
    }
    System.err.println(Joiner.on("\n").join(tags));
}

From source file:com.act.lcms.db.analysis.BestMoleculesPickerFromLCMSIonAnalysis.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());/*from  w w w  .  ja va 2 s .  c o m*/
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        HELP_FORMATTER.printHelp(BestMoleculesPickerFromLCMSIonAnalysis.class.getCanonicalName(), HELP_MESSAGE,
                opts, null, true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(BestMoleculesPickerFromLCMSIonAnalysis.class.getCanonicalName(), HELP_MESSAGE,
                opts, null, true);
        System.exit(1);
    }

    List<String> positiveReplicateResults = new ArrayList<>(
            Arrays.asList(cl.getOptionValues(OPTION_INPUT_FILES)));

    if (cl.hasOption(OPTION_MIN_OF_REPLICATES)) {
        HitOrMissReplicateFilterAndTransformer transformer = new HitOrMissReplicateFilterAndTransformer();

        List<IonAnalysisInterchangeModel> models = positiveReplicateResults.stream().map(file -> {
            try {
                return IonAnalysisInterchangeModel.loadIonAnalysisInterchangeModelFromFile(file);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }).collect(Collectors.toList());

        IonAnalysisInterchangeModel transformedModel = IonAnalysisInterchangeModel
                .filterAndOperateOnMoleculesFromMultipleReplicateModels(models, transformer);

        printInchisAndIonsToFile(transformedModel, cl.getOptionValue(OPTION_OUTPUT_FILE),
                cl.hasOption(OPTION_JSON_FORMAT));
        return;
    }

    Double minSnrThreshold = Double.parseDouble(cl.getOptionValue(OPTION_MIN_SNR_THRESHOLD));
    Double minIntensityThreshold = Double.parseDouble(cl.getOptionValue(OPTION_MIN_INTENSITY_THRESHOLD));
    Double minTimeThreshold = Double.parseDouble(cl.getOptionValue(OPTION_MIN_TIME_THRESHOLD));

    if (cl.hasOption(OPTION_GET_IONS_SUPERSET)) {
        List<IonAnalysisInterchangeModel> models = positiveReplicateResults.stream().map(file -> {
            try {
                return IonAnalysisInterchangeModel.loadIonAnalysisInterchangeModelFromFile(file);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }).collect(Collectors.toList());

        IonAnalysisInterchangeModel transformedModel = IonAnalysisInterchangeModel
                .getSupersetOfIonicVariants(models, minSnrThreshold, minIntensityThreshold, minTimeThreshold);

        printInchisAndIonsToFile(transformedModel, cl.getOptionValue(OPTION_OUTPUT_FILE),
                cl.hasOption(OPTION_JSON_FORMAT));
        return;
    }

    if (cl.hasOption(OPTION_THRESHOLD_ANALYSIS)) {

        if (positiveReplicateResults.size() > 1) {
            LOGGER.error("Since this is a threshold analysis, the number of positive replicates should be 1.");
            System.exit(1);
        }

        // We need to set this variable as a final since it is used in a lambda function below.
        final Set<String> ions = new HashSet<>();
        if (cl.hasOption(OPTION_FILTER_BY_IONS)) {
            ions.addAll(Arrays.asList(cl.getOptionValues(OPTION_FILTER_BY_IONS)));
        }

        HitOrMissSingleSampleFilterAndTransformer hitOrMissSingleSampleTransformer = new HitOrMissSingleSampleFilterAndTransformer(
                minIntensityThreshold, minSnrThreshold, minTimeThreshold, ions);

        IonAnalysisInterchangeModel model = IonAnalysisInterchangeModel.filterAndOperateOnMoleculesFromModel(
                IonAnalysisInterchangeModel.loadIonAnalysisInterchangeModelFromFile(
                        positiveReplicateResults.get(0)),
                hitOrMissSingleSampleTransformer);

        printInchisAndIonsToFile(model, cl.getOptionValue(OPTION_OUTPUT_FILE),
                cl.hasOption(OPTION_JSON_FORMAT));
    }
}

From source file:com.genentech.chemistry.openEye.apps.SDFTopologicalIndexer.java

/**
 * @param args//  ww  w .  j a v  a  2  s.  com
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    if (args.length == 0) {
        System.err.println("Specify at least one index type");
        exitWithHelp(options);
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    Set<String> selectedIndexes = new HashSet<String>(args.length);
    if (args.length == 1 && "all".equalsIgnoreCase(args[0]))
        selectedIndexes = AVAILIndexes;
    else
        selectedIndexes.addAll(Arrays.asList(args));

    if (!AVAILIndexes.containsAll(selectedIndexes)) {
        selectedIndexes.removeAll(AVAILIndexes);
        StringBuilder err = new StringBuilder("Unknown Index types: ");
        for (String it : selectedIndexes)
            err.append(it).append(" ");
        System.err.println(err);
        exitWithHelp(options);
    }

    SDFTopologicalIndexer sdfIndexer = new SDFTopologicalIndexer(outFile, selectedIndexes);

    sdfIndexer.run(inFile);
    sdfIndexer.close();
}