Example usage for com.google.common.collect Iterables toString

List of usage examples for com.google.common.collect Iterables toString

Introduction

In this page you can find the example usage for com.google.common.collect Iterables toString.

Prototype

public static String toString(Iterable<?> iterable) 

Source Link

Document

Returns a string representation of iterable , with the format [e1, e2, ..., en] (that is, identical to java.util.Arrays Arrays .toString(Iterables.toArray(iterable)) ).

Usage

From source file:edu.umn.msi.tropix.proteomics.itraqquantitation.impl.WeightedRatiosCalculatorImpl.java

public Ratios computeRatios(final ITraqLabel numLabel, final ITraqLabel denLabel,
        final ReportSummary reportSummary, final Function<Double, Double> weightFunction,
        final boolean normalized) {
    final double[] ratios = new double[reportSummary.getNumGroups()],
            pValues = new double[reportSummary.getNumGroups()];
    int groupNum = 0;
    for (final String groupLabel : reportSummary.getGroups()) {
        final GroupSummary proteinSummary = reportSummary.getGroupSummary(groupLabel);
        final double[] iRatio = new double[proteinSummary.getNumEntries()];
        final double[] num = proteinSummary.getIntensities(numLabel);
        final double[] den = proteinSummary.getIntensities(denLabel);

        double[] weights = proteinSummary.getLogIntensitiesProducts();
        if (weightFunction != null) {
            final double[] modifiedWeights = new double[weights.length];
            for (int i = 0; i < weights.length; i++) {
                modifiedWeights[i] = weightFunction.apply(weights[i]);
            }//from   w ww .j a  v  a2 s .  c om
            weights = modifiedWeights;
        }

        for (int i = 0; i < iRatio.length; i++) {
            iRatio[i] = Math.log(num[i] / den[i]);
        }

        // final String logRatioStr = Iterables.toString(Doubles.asList(iRatio));
        // System.out.println(logRatioStr);

        if (normalized) {
            final double median = RUtils.median(iRatio);
            for (int i = 0; i < iRatio.length; i++) {
                iRatio[i] = iRatio[i] / median;
            }
        }

        final double iRatioW1 = RUtils.weightedMean(iRatio, weights);
        final double iRatioW = Math.exp(iRatioW1);
        double pValue = 2.0;
        if (iRatio.length > 2) {
            pValue = RMethods.getWeightedPValue(iRatio, weights);
        }

        if (pValue < 0) {
            // This hasn't been a problem since upgrading commons-math
            final String ratioStr = Iterables.toString(Doubles.asList(iRatio));
            final String weightsStr = Iterables.toString(Doubles.asList(weights));
            System.out.println(String.format("Negative p-value found for ratios %s and weights %s.", ratioStr,
                    weightsStr));
        }

        ratios[groupNum] = iRatioW;
        pValues[groupNum] = pValue;

        groupNum++;
    }

    return new Ratios(ratios, pValues);
}

From source file:brooklyn.location.docker.strategy.affinity.DockerAffinityRuleStrategy.java

@Override
public List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity entity) {
    List<DockerHostLocation> available = Lists.newArrayList();

    // Select hosts that satisfy the affinity rules
    for (DockerHostLocation machine : locations) {
        Optional<List<String>> entityRules = Optional
                .fromNullable(entity.config().get(DockerHost.DOCKER_HOST_AFFINITY_RULES));
        Optional<List<String>> hostRules = Optional
                .fromNullable(machine.getOwner().config().get(DockerHost.DOCKER_HOST_AFFINITY_RULES));
        Optional<List<String>> infrastructureRules = Optional.fromNullable(
                machine.getOwner().getInfrastructure().config().get(DockerHost.DOCKER_HOST_AFFINITY_RULES));
        Iterable<String> combined = Iterables.concat(
                Optional.presentInstances(ImmutableList.of(entityRules, hostRules, infrastructureRules)));
        AffinityRules rules = AffinityRules.rulesFor(entity).parse(combined);

        Iterable<Entity> entities = getBrooklynManagementContext().getEntityManager()
                .findEntities(EntityPredicates.locationsIncludes(machine));
        if (Iterables.isEmpty(entities)) {
            if (rules.allowEmptyLocations()) {
                available.add(machine);/*from w w w  .j ava  2 s . c  om*/
            }
        } else {
            Iterable<Entity> filtered = Iterables.filter(entities, rules);
            if (Iterables.size(filtered) == Iterables.size(entities)) {
                available.add(machine);
            }
        }
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Available Docker hosts: {}", Iterables.toString(available));
    }
    return available;
}

From source file:us.eharning.atomun.mnemonic.spi.electrum.v2.MnemonicBuilderSpiImpl.java

/**
 * Checks that the given extension parameter is valid.
 *
 * @param parameter//from w ww .  j a va  2s .c om
 *         instance containing extension parameters.
 *
 * @throws IllegalArgumentException
 *         if the parameter contains unknown parameters.
 */
private static void checkExtensionNames(ExtensionBuilderParameter parameter) {
    Map<String, Object> extensions = parameter.getExtensions();
    if (!KNOWN_EXTENSION_NAMES.containsAll(extensions.keySet())) {
        Iterable<String> unknownNames = Iterables.filter(extensions.keySet(),
                Predicates.not(Predicates.in(KNOWN_EXTENSION_NAMES)));
        throw new IllegalArgumentException(
                "Found unhandled extension names: " + Iterables.toString(unknownNames));
    }
}

From source file:org.impressivecode.depress.scm.common.SCMInputTransformer.java

@Override
public InputTransformer<SCMDataType> validate() throws InvalidSettingsException {
    checkNotNull(this.minimalTableSpec, "Minimal DataTableSpec hat to be set");
    checkNotNull(this.inputTableSpec, "Input DataTableSpec hat to be set");

    Set<String> missing = DataTableSpecUtils.findMissingColumnSubset(this.inputTableSpec,
            this.minimalTableSpec);
    if (!missing.isEmpty()) {
        throw new InvalidSettingsException("History data table does not contain required columns. Missing: "
                + Iterables.toString(missing));
    }//from   w w w  . j a v  a 2s .c om
    return this;
}

From source file:mvm.rya.api.persist.query.BatchRyaQuery.java

@Override
public String toString() {
    return "BatchRyaQuery{" + "queries=" + Iterables.toString(queries) + "options={" + super.toString() + '}'
            + '}';
}

From source file:org.jclouds.vcloud.director.v1_5.predicates.EntityPredicates.java

/**
 * Matches {@link EntityType entities} with names in the given collection.
 *
 * @param T type of the entity, for example {@link Vm}
 * @param names collection of values for the name attribute of the entity
 * @return predicate that will match entities with names starting with the given prefix
 *///from   w w w  . ja va2s .  c  o m
public static <T extends Entity> Predicate<T> nameIn(final Iterable<String> names) {
    checkNotNull(names, "names must be defined");

    return new Predicate<T>() {
        @Override
        public boolean apply(T entity) {
            String name = entity.getName();
            return Iterables.contains(names, name);
        }

        @Override
        public String toString() {
            return "nameIn(" + Iterables.toString(names) + ")";
        }
    };
}

From source file:eu.interedition.collatex.jung.JungVariantGraphVertex.java

@Override
public String toString() {
    return Iterables.toString(tokens);
}

From source file:org.eclipse.xtend.maven.AbstractXtend2CompilerMojo.java

protected void compile(XtendBatchCompiler xtend2BatchCompiler, String classPath, List<String> sourceDirectories,
        String outputPath) throws MojoExecutionException {
    Iterable<String> filtered = filter(sourceDirectories, FILE_EXISTS);
    if (Iterables.isEmpty(filtered)) {
        getLog().info("skip compiling sources because the configured directory '"
                + Iterables.toString(sourceDirectories) + "' does not exists.");
        return;//from  www.jav a 2 s . c  o m
    }
    getLog().debug("Set temp directory: " + getTempDirectory());
    xtend2BatchCompiler.setTempDirectory(getTempDirectory());
    getLog().debug("Set DeleteTempDirectory: " + false);
    xtend2BatchCompiler.setDeleteTempDirectory(false);
    getLog().debug("Set classpath: " + classPath);
    xtend2BatchCompiler.setClassPath(classPath);
    getLog().debug("Set source path: " + concat(File.pathSeparator, newArrayList(filtered)));
    xtend2BatchCompiler.setSourcePath(concat(File.pathSeparator, newArrayList(filtered)));
    getLog().debug("Set output path: " + outputPath);
    xtend2BatchCompiler.setOutputPath(outputPath);
    getLog().debug("Set encoding: " + encoding);
    xtend2BatchCompiler.setFileEncoding(encoding);
    if (!xtend2BatchCompiler.compile()) {
        throw new MojoExecutionException("Error compiling xtend sources in '"
                + concat(File.pathSeparator, newArrayList(filtered)) + "'.");
    }
}

From source file:com.google.devtools.build.lib.events.EventCollector.java

@Override
public synchronized String toString() {
    return "EventCollector: " + Iterables.toString(collected);
}

From source file:org.eclipse.jdt.ls.core.internal.highlighting.SemanticHighlightingService.java

/**
 * Returns with the scope for the index. If not found, throws an exception.
 *//*from   ww  w  .j a v  a2 s  .co  m*/
public static int getIndex(List<String> scopes) {
    Integer index = LOOKUP_TABLE.inverse().get(scopes);
    Assert.isNotNull(index, "Cannot get index for scopes: " + Iterables.toString(scopes));
    return index;
}