Java Code Examples for gnu.trove.map.hash.THashMap#put()

The following examples show how to use gnu.trove.map.hash.THashMap#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CLIParserBenchmarker.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public THashMap<String, String> parse(String[] input) {
	THashMap<String, String> result = new THashMap<>();
	try {
		CommandLine cmdLine = this.parse(this.getOptions(), input);
		for (Option option : cmdLine.getOptions()) {
			result.put(option.getOpt(), option.getValue());
		}
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return result;
}
 
Example 2
Source File: reading.java    From systemsgenetics with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Read annotation file.
 * General read in
 * @param annotationFile
 * @param storingId
 * @param sizeMap
 * @return 
 */
public static THashMap<String, THashMap<String, String>> readAnnotationFile(String annotationFile, int storingId, int sizeMap) {
    THashMap<String, THashMap<String, String>> probeInfo = new THashMap<String, THashMap<String, String>>((int) Math.ceil(sizeMap / 0.75));
    int entryId = 0;
    try {
        TextFile in = new TextFile(annotationFile, TextFile.R);
        String str = "";

        str = in.readLine();
        String[] header = SPLIT_ON_TAB.split(str);


        while ((str = in.readLine()) != null) {
            String[] strParts = SPLIT_ON_TAB.split(str);
            THashMap<String, String> t = new THashMap<String, String>((int) Math.ceil(header.length / 0.75));
            for (int i = 0; i < strParts.length; ++i) {
                if (i != storingId) {
                    t.put(header[i], strParts[i]);
                }
            }
            if (storingId == -1) {
                probeInfo.put(String.valueOf(entryId), t);
                entryId++;
            } else if (storingId == -2) {
                probeInfo.put(strParts[0]+"-"+strParts[1]+"-"+strParts[28], t);
                entryId++;
            }else {
                probeInfo.put(strParts[storingId], t);
            }

        }
    } catch (IOException e) {
        e.printStackTrace();
        System.out.println(e.getMessage());
        System.exit(-1);
    }

    return (probeInfo);
}
 
Example 3
Source File: TinkerGraph.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
/**
 * retrieve the correct by-label map (and create it if it doesn't yet exist)
 */
protected <E extends Element> Set<E> getElementsByLabel(final THashMap<String, Set<E>> elementsByLabel, final String label) {
    if (!elementsByLabel.containsKey(label))
        elementsByLabel.put(label, new THashSet<>(100000));
    return elementsByLabel.get(label);
}
 
Example 4
Source File: TriTyperGeneticalGenomicsDataset.java    From systemsgenetics with GNU General Public License v3.0 4 votes vote down vote up
public void pruneGenotypeToExpressionCouplings() {
	// now check whether each genotype is actually linked to an expression individual...
	String[] individuals = genotypeData.getIndividuals();

	Boolean[] isReallyIncluded = new Boolean[individuals.length];
	THashMap<String, String> realGenotypeToExpressionCouplings = new THashMap<String, String>();
	totalGGSamples = 0;
	for (int i = 0; i < isReallyIncluded.length; i++) {
		String genotypeInd = individuals[i];
		if (!genotypeToExpressionCouplings.containsKey(genotypeInd)) {
			isReallyIncluded[i] = false;
		} else {
			String coupledExpressionSample = genotypeToExpressionCouplings.get(genotypeInd);
			if (coupledExpressionSample != null) {
				Integer expressionSampleId = expressionData.getIndividualId(coupledExpressionSample);
				if (expressionSampleId == -9) {
					isReallyIncluded[i] = false;
				} else {
					isReallyIncluded[i] = true;
					realGenotypeToExpressionCouplings.put(genotypeInd, coupledExpressionSample);
					totalGGSamples++;
				}
			}
		}
	}

	// exclude genotypes for which no expression data is available.
	genotypeData.setIsIncluded(isReallyIncluded);
	genotypeToExpressionCouplings = realGenotypeToExpressionCouplings;

	// couple expression IDs to genotype IDs for quick reference
	Set<Entry<String, String>> entries = realGenotypeToExpressionCouplings.entrySet();
	expressionToGenotypeIdArray = new short[totalGGSamples];
	HashSet<Integer> visitedNumbers = new HashSet<Integer>();
	for (Entry<String, String> entry : entries) {
		Integer expressionIndId = expressionData.getIndividualId(entry.getValue());
		Integer genotypeIndId = genotypeData.getIndividualId(entry.getKey());
		if (expressionIndId != -9 && genotypeIndId != -9) {
			if (visitedNumbers.contains(expressionIndId)) {
				System.out.println("ERROR: your dataset contains duplicate samples!");
			} else {
				expressionToGenotypeIdArray[expressionIndId] = genotypeIndId.shortValue();
				visitedNumbers.add(expressionIndId);
			}
		}
	}
}