private Variant parseVariant(String line) throws IOException { Map<String, Object> map = (HashMap<String, Object>) new ObjectMapper().readValue(line, HashMap.class); if (assembly.equalsIgnoreCase((String) map.get(REFERENCE_VERSION))) { Variant variant = new Variant((String) map.get(CHROMOSOME), (Integer) map.get(START), (String) map.get(REFERENCE), (String) map.get(VARIANT)); VariantAnnotation variantAnnotation = parseVariantAnnotation(map); variant.setAnnotation(variantAnnotation); return variant; } else { return null; } }
public QueryResponse<Variant> annotate(List<Variant> variants, QueryOptions options, boolean post) throws IOException { List<String> variantIds = getVariantAnnotationIds(variants); QueryResponse<VariantAnnotation> annotations = this.getAnnotationByVariantIds(variantIds, options, post); int timePerId = annotations.getTime() / variants.size(); List<QueryResult<Variant>> annotatedVariants = new ArrayList<>(variants.size()); for (int i = 0; i < variants.size(); i++) { variants.get(i).setAnnotation(annotations.getResponse().get(i).first()); annotatedVariants.add(new QueryResult<>(variantIds.get(i), timePerId, 1, 1, "", "", Collections.singletonList(variants.get(i)))); } return new QueryResponse<>(configuration.getVersion(), annotations.getTime(), options, annotatedVariants); }
public QueryResponse<Variant> annotate(List<Variant> variants, QueryOptions options, boolean post) throws IOException { List<String> variantIds = getVariantAnnotationIds(variants); QueryResponse<VariantAnnotation> annotations = this.getAnnotationByVariantIds(variantIds, options, post); int timePerId = annotations.getTime() / variants.size(); List<QueryResult<Variant>> annotatedVariants = new ArrayList<>(variants.size()); for (int i = 0; i < variants.size(); i++) { variants.get(i).setAnnotation(annotations.getResponse().get(i).first()); annotatedVariants.add(new QueryResult<>(variantIds.get(i), timePerId, 1, 1, "", "", Collections.singletonList(variants.get(i)))); } return new QueryResponse<>(configuration.getVersion(), annotations.getTime(), options, annotatedVariants); }
public void run(List<Variant> variantList) { if (variantList != null && !variantList.isEmpty()) { logger.debug("Annotator sends {} new variants for annotation. Waiting for the result", variantList.size()); QueryResponse<VariantAnnotation> response; try { response = variantClient.getAnnotationByVariantIds(variantList.stream().map(Variant::toString).collect(Collectors.toList()), queryOptions, true); } catch (IOException e) { e.printStackTrace(); return; } //TODO: assuming CellBase annotation will always be the first and therefore variantAnnotationList will be empty // variantAnnotationList = new ArrayList<>(variantList.size()); // List<QueryResult<QueryResult<VariantAnnotation>>> response1 = response.getResponse(); List<QueryResult<VariantAnnotation>> queryResultList = response.getResponse(); for (int i = 0; i < queryResultList.size(); i++) { if (queryResultList.get(i).getResult().size() > 0) { if (variantList.get(i).getAnnotation() == null) { variantList.get(i).setAnnotation(queryResultList.get(i).getResult().get(0)); } else { mergeAnnotation(variantList.get(i).getAnnotation(), queryResultList.get(i).getResult().get(0)); } } else { logger.warn("Emtpy result for '{}'", queryResultList.get(i).getId()); } } } }
protected Variant convert(Variant variant, Map<Integer, StudyEntry> studies, VariantAnnotation annotation) { for (StudyEntry studyEntry : studies.values()) { variant.addStudyEntry(studyEntry); } variant.setAnnotation(annotation); if (annotation != null && StringUtils.isNotEmpty(annotation.getId())) { variant.setId(annotation.getId()); } else { variant.setId(variant.toString()); } if (failOnEmptyVariants && variant.getStudies().isEmpty()) { throw new IllegalStateException("No Studies registered for variant!!! " + variant); } return variant; }
mustSearchVariation.get(i).setAnnotation(new VariantAnnotation()); if (mustSearchVariation.get(i).getAnnotation() == null) { variantAnnotation = cacheVariant.getAnnotation(); mustSearchVariation.get(i).setAnnotation(variantAnnotation); } else { variantAnnotation = mustSearchVariation.get(i).getAnnotation();
mustSearchVariation.get(i).setAnnotation(new VariantAnnotation()); if (mustSearchVariation.get(i).getAnnotation() == null) { variantAnnotation = cacheVariant.getAnnotation(); mustSearchVariation.get(i).setAnnotation(variantAnnotation); } else { variantAnnotation = mustSearchVariation.get(i).getAnnotation();
@Override public boolean write(Variant variant) { ArrayList<PopulationFrequency> frequencies = new ArrayList<>(); for (StudyEntry studyEntry : variant.getStudies()) { for (Map.Entry<String, VariantStats> cohortEntry : studyEntry.getStats().entrySet()) { String studyId = studyEntry.getStudyId(); studyId = studyId.substring(studyId.lastIndexOf(":") + 1); PopulationFrequency populationFrequency = converter.convert(studyId, cohortEntry.getKey(), cohortEntry.getValue(), variant.getReference(), variant.getAlternate()); // Write only frequencies non zero if (populationFrequency.getAltAlleleFreq() > 0 && !populationFrequency.getAltAlleleFreq().isNaN()) { frequencies.add(populationFrequency); } } } Variant newVar = new Variant(variant.toString()); VariantAnnotation annotation = new VariantAnnotation(); annotation.setPopulationFrequencies(frequencies); newVar.setAnnotation(annotation); try { sequenceWriter.write(newVar); outputStream.write('\n'); } catch (IOException e) { throw new UncheckedIOException(e); } return true; } }
private void serializeRDB(RocksDB rdb) throws IOException { // DO NOT change the name of the rocksIterator variable - for some unexplainable reason Java VM crashes if it's // named "iterator" RocksIterator rocksIterator = rdb.newIterator(); ObjectMapper mapper = new ObjectMapper(); logger.info("Reading from RoocksDB index and serializing to {}.json.gz", serializer.getOutdir().resolve(serializer.getFileName())); int counter = 0; for (rocksIterator.seekToFirst(); rocksIterator.isValid(); rocksIterator.next()) { VariantAnnotation variantAnnotation = mapper.readValue(rocksIterator.value(), VariantAnnotation.class); // List<EvidenceEntry> evidenceEntryList // = mapper.readValue(rocksIterator.value(), List.class); Variant variant = parseVariantFromVariantId(new String(rocksIterator.key())); // VariantAnnotation variantAnnotation = new VariantAnnotation(); // variantAnnotation.setTraitAssociation(evidenceEntryList); variant.setAnnotation(variantAnnotation); serializer.serialize(variant); counter++; if (counter % 10000 == 0) { logger.info("{} written", counter); } } serializer.close(); logger.info("Done."); }
null, null, null, null, null, null, additionalAttributes); variant.setAnnotation(variantAnnotation); variant.setStrand(strand);
private Map<String, Variant> buildVariantsIdx() throws Exception { VariantHadoopDBAdaptor dbAdaptor = getVariantStorageEngine().getDBAdaptor(); Map<String, Variant> variants = new HashMap<>(); System.out.println("Build Variant map"); for (Variant variant : dbAdaptor) { if (variant.getStudies().isEmpty()) { continue; } String v = variant.toString(); assertFalse(variants.containsKey(v)); variants.put(v, variant); VariantAnnotation a = variant.getAnnotation(); variant.setAnnotation(null); System.out.println(variant.toJson()); variant.setAnnotation(a); } System.out.println("End. size : " + variants.size()); return variants; }
structuralVariation.setCiEndRight(variant.getEnd()); variant.setAnnotation(annotation); variant.setSv(structuralVariation); variant.setId(fields[ACCESSION_COLUMN]);
variant.setAnnotation(getVariantAnnotation(variantSearchModel, variant));
if (normalizedVariantList.get(i).getAnnotation() == null) { variantAnnotation = new VariantAnnotation(); normalizedVariantList.get(i).setAnnotation(variantAnnotation); } else { variantAnnotation = normalizedVariantList.get(i).getAnnotation();
variant.setStrand(strand); variant.setType(VariantType.valueOf(variantType)); variant.setAnnotation(null); variant.setHgvs(null); return variant;
v.setIds(var.getIds()); v.setStrand(var.getStrand()); v.setAnnotation(var.getAnnotation());
actual.setAnnotation(null);
variant.setAnnotation(annotation);
.append(VariantQueryParam.INCLUDE_FORMAT.key(), "GT,GL,DS"), new QueryOptions()).first(); loadedVariant.setAnnotation(null); //Remove annotation StudyEntry loadedStudy = loadedVariant.getStudy(STUDY_NAME);
variants.get(i).setAnnotation(queryResponse.getResponse().get(i).first());