Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoids errors due to non parseable integer elements OT percentile ranks #112

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import com.google.gson.JsonPrimitive;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.ebi.atlas.commons.readers.TsvStreamer;
import uk.ac.ebi.atlas.commons.streams.ObjectInputStream;
import uk.ac.ebi.atlas.home.AtlasInformationDao;
import uk.ac.ebi.atlas.model.experiment.sample.AssayGroup;
import uk.ac.ebi.atlas.model.GeneProfilesList;
import uk.ac.ebi.atlas.model.OntologyTerm;
Expand All @@ -29,23 +32,22 @@

import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.stream.Collectors.joining;

public class EvidenceService<X extends DifferentialExpression,
E extends DifferentialExperiment,
O extends DifferentialProfileStreamOptions,
P extends Profile<Contrast, X, P>> {
private static final double MIN_P_VALUE = 1e-234;
private static final String ACTIVITY_URL_TEMPLATE = "http://identifiers.org/cttv.activity/{0}";
private static final Logger LOGGER = LoggerFactory.getLogger(EvidenceService.class);


private final ProfileStreamFactory<Contrast, X, E, O, P> differentialProfileStreamFactory;
private final DataFileHub dataFileHub;
Expand Down Expand Up @@ -477,7 +479,7 @@ public static DiseaseAssociation create(SampleCharacteristic biosampleInfo,
private static String factorBasedSummaryLabel(final ExperimentDesign experimentDesign, AssayGroup assayGroup) {
return experimentDesign.getFactorValues(assayGroup.getFirstAssayId()).values().stream()
.filter(StringUtils::isNotEmpty)
.collect(Collectors.joining("; "));
.collect(joining("; "));
}

/*
Expand Down Expand Up @@ -555,17 +557,24 @@ private Map<String, Map<Contrast, Integer>> readPercentileRanks(E experiment, Ob
var whichContrastInWhichLine = percentileRanksColumnsFromHeader(lines.readNext(), experiment);
var geneToRankedContrast = new HashMap<String, Map<Contrast, Integer>>();

var unparseableNumbers = new HashSet<String>();
for (var line : new IterableObjectInputStream<>(lines)) {
var resultForThisGene = new HashMap<Contrast, Integer>();

for (var entry : whichContrastInWhichLine.entrySet()) {
String value = line[entry.getKey()];
if (!"NA".equals(value)) {
try {
resultForThisGene.put(entry.getValue(), Integer.parseInt(value));
} catch (NumberFormatException e) {
unparseableNumbers.add(value);
}
}
geneToRankedContrast.put(line[0], resultForThisGene);
}
if (unparseableNumbers.size() > 0) {
var examples = unparseableNumbers.stream().map(item -> "'"+item+"'").collect(joining(", "));
LOGGER.warn("%s percentile ranks file has the following unparseable text entries: %s", experiment.getAccession(), examples);
}

return geneToRankedContrast;
}
Expand Down