Java Code Examples for gnu.trove.map.TObjectIntMap#adjustOrPutValue()

The following examples show how to use gnu.trove.map.TObjectIntMap#adjustOrPutValue() . 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: Utils.java    From apkfile with Apache License 2.0 5 votes vote down vote up
public static void updateAccessorCounts(TObjectIntMap<String> counts, int[] accessFlags) {
    for (int accessFlag : accessFlags) {
        if (Modifier.isPublic(accessFlag)) {
            counts.adjustOrPutValue("public", 1, 1);
        }
        if (Modifier.isProtected(accessFlag)) {
            counts.adjustOrPutValue("protected", 1, 1);
        }
        if (Modifier.isPrivate(accessFlag)) {
            counts.adjustOrPutValue("private", 1, 1);
        }
        if (Modifier.isFinal(accessFlag)) {
            counts.adjustOrPutValue("final", 1, 1);
        }
        if (Modifier.isInterface(accessFlag)) {
            counts.adjustOrPutValue("interface", 1, 1);
        }
        if (Modifier.isNative(accessFlag)) {
            counts.adjustOrPutValue("native", 1, 1);
        }
        if (Modifier.isStatic(accessFlag)) {
            counts.adjustOrPutValue("static", 1, 1);
        }
        if (Modifier.isStrict(accessFlag)) {
            counts.adjustOrPutValue("strict", 1, 1);
        }
        if (Modifier.isSynchronized(accessFlag)) {
            counts.adjustOrPutValue("synchronized", 1, 1);
        }
        if (Modifier.isTransient(accessFlag)) {
            counts.adjustOrPutValue("transient", 1, 1);
        }
        if (Modifier.isVolatile(accessFlag)) {
            counts.adjustOrPutValue("volatile", 1, 1);
        }
        if (Modifier.isAbstract(accessFlag)) {
            counts.adjustOrPutValue("abstract", 1, 1);
        }
    }
}
 
Example 2
Source File: Utils.java    From apkfile with Apache License 2.0 4 votes vote down vote up
public static void rollUp(TObjectIntMap dest, TObjectIntMap src) {
    for (Object key : src.keySet()) {
        int value = src.get(key);
        dest.adjustOrPutValue(key, value, value);
    }
}
 
Example 3
Source File: InvestigateString.java    From systemsgenetics with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * @param args the command line arguments
	 * @throws java.io.FileNotFoundException
	 */
	public static void main(String[] args) throws FileNotFoundException, IOException, Exception {

		final File stringFile = new File("C:\\UMCG\\Genetica\\Projects\\GeneNetwork\\String\\9606.protein.links.full.v10.5.txt");
		final File ensgEnspFile = new File("C:\\UMCG\\Genetica\\Projects\\GeneNetwork\\ensgGeneProteinV83.txt");

		HashMap<String, String> enspToEnsgMap = loadEnspToEnsgMap(ensgEnspFile);

		final CSVParser parser = new CSVParserBuilder().withSeparator(' ').withIgnoreQuotations(true).build();
		final CSVReader sampleFileReader = new CSVReaderBuilder(new BufferedReader(new FileReader(stringFile))).withSkipLines(1).withCSVParser(parser).build();

		HashSet<GenePair> observedGenePairs = new HashSet<>();
		TObjectIntMap<String> geneCombinedConfidentCount = new TObjectIntHashMap<>();
		TObjectIntMap<String> geneCombinedCoexpressionCount = new TObjectIntHashMap<>();

		String[] nextLine;
		while ((nextLine = sampleFileReader.readNext()) != null) {

			final String protein1 = nextLine[0].substring(5);
			final String protein2 = nextLine[1].substring(5);

			final String gene1 = enspToEnsgMap.get(protein1);
			final String gene2 = enspToEnsgMap.get(protein2);
		

			if (gene1 == null || gene2 == null) {
				continue;
			}

			GenePair gene1Gene2Pair = new GenePair(gene1, gene2);
			if (observedGenePairs.add(gene1Gene2Pair)) {

				if (Integer.parseInt(nextLine[15]) >= 700) {
					geneCombinedConfidentCount.adjustOrPutValue(gene1, 1, 1);
					geneCombinedConfidentCount.adjustOrPutValue(gene2, 1, 1);
				}
				
				if (Integer.parseInt(nextLine[8]) >= 700) {
					geneCombinedCoexpressionCount.adjustOrPutValue(gene1, 1, 1);
					geneCombinedCoexpressionCount.adjustOrPutValue(gene2, 1, 1);
				}

			} else {
//				System.out.println("Observed duplicate pair");
//				System.out.println(protein1);
//				System.out.println(protein2);
//				System.out.println(gene1);
//				System.out.println(gene2);

			}

		}
		
		System.out.println("Gene\tCoexpressionCount\tCombinedCount");
		for(String gene : geneCombinedConfidentCount.keySet()){
			System.out.println(gene + "\t" + geneCombinedCoexpressionCount.get(gene) + "\t" + geneCombinedConfidentCount.get(gene)) ;
		}

		System.out.println("Total unique interactions: " + observedGenePairs.size());

	}