congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
StudyEntry.getFormat
Code IndexAdd Tabnine to your IDE (free)

How to use
getFormat
method
in
org.opencb.biodata.models.variant.StudyEntry

Best Java code snippets using org.opencb.biodata.models.variant.StudyEntry.getFormat (Showing top 20 results out of 315)

origin: org.opencb.biodata/biodata-models

public Map<String, Integer> getFormatPositions() {
  if (Objects.isNull(this.formatPosition.get())) {
    Map<String, Integer> map = new HashMap<>();
    int pos = 0;
    if (getFormat() != null) {
      for (String format : getFormat()) {
        map.put(format, pos++);
      }
    }
    this.formatPosition.compareAndSet(null, map);
  }
  return formatPosition.get();
}
origin: opencb/opencga

private int[] buildFormatRemap(StudyEntry studyEntry) {
  int[] formatReMap;
  if (fixedFormat.equals(studyEntry.getFormat())) {
    formatReMap = null;
  } else {
    formatReMap = new int[fixedFormat.size()];
    for (int i = 0; i < fixedFormat.size(); i++) {
      String format = fixedFormat.get(i);
      Integer idx = studyEntry.getFormatPositions().get(format);
      if (idx == null) {
        if (format.equals(VariantMerger.GENOTYPE_FILTER_KEY)) {
          idx = FILTER_FIELD;
        } else {
          idx = UNKNOWN_FIELD;
        }
      }
      formatReMap[i] = idx;
    }
  }
  return formatReMap;
}
origin: org.opencb.biodata/biodata-models

public StudyEntry addSampleData(String sampleName, Map<String, String> sampleData) {
  if (getFormat() == null) {
    setFormat(new ArrayList<>(sampleData.keySet()));
  }
  List<String> sampleDataList = new ArrayList<>(getFormat().size());
  for (String field : getFormat()) {
    sampleDataList.add(sampleData.get(field));
  }
  if (sampleData.size() != sampleDataList.size()) {
    List<String> extraFields = sampleData.keySet().stream().filter(f -> getFormat().contains(f)).collect(Collectors.toList());
    throw new IllegalArgumentException("Some sample data fields were not in the format field: " + extraFields);
  }
  addSampleData(sampleName, sampleDataList);
  return this;
}
origin: opencb/opencga

    variant.getAlternate());
StudyEntry studyEntry = new StudyEntry();
studyEntry.setFormat(archiveVariant.getStudies().get(0).getFormat());
studyEntry.setSortedSamplesPosition(new LinkedHashMap<>());
studyEntry.setSamplesData(new ArrayList<>());
origin: org.opencb.biodata/biodata-tools

private List<String> setFormat(Builder recordBuilder, StudyEntry study) {
  String formatAsString;
  List<String> formatList;
  if (includeAllFormats) {
    formatList = study.getFormat();
  } else {
    formatList = study.getFormat()
        .stream()
        .filter(formatFields::contains)
        .collect(Collectors.toList());
  }
  formatAsString = String.join(":", formatList);
  Integer formatIndex = formatIndexMap.get(formatAsString);
  if (formatIndex == null || formatIndex < 0) {
    throw new IllegalArgumentException("Unknown format " + formatAsString);
  }
  recordBuilder.setFormatIndex(formatIndex);
  return formatList;
}
origin: org.opencb.biodata/biodata-models

public Map<String, String> getSampleDataAsMap(String sampleName) {
  requireSamplesPosition();
  if (samplesPosition.containsKey(sampleName)) {
    HashMap<String, String> sampleDataMap = new HashMap<>();
    Iterator<String> iterator = getFormat().iterator();
    List<String> sampleDataList = impl.getSamplesData().get(samplesPosition.get(sampleName));
    for (String data : sampleDataList) {
      sampleDataMap.put(iterator.next(), data);
    }
    return Collections.unmodifiableMap(sampleDataMap);
  }
  return null;
}
origin: org.opencb.biodata/biodata-tools

  private void isValidVariant(Variant current) throws IllegalArgumentException{
    if (current.getType().equals(VariantType.NO_VARIATION)) {
      throw new IllegalStateException("Current variant can't be a NO_VARIANT");
    }

    // Validate variant information
//        ensureGtFormat(current);
    if (getStudy(current).getFormat() == null || getStudy(current).getFormat().isEmpty()) {
      throw new IllegalArgumentException("Format of sample data is empty!!!!!!");
    }
  }

origin: opencb/cellbase

private boolean isPhased(Variant variant) {
  return (variant.getStudies() != null && !variant.getStudies().isEmpty())
    && variant.getStudies().get(0).getFormat().contains("PS");
}
origin: org.opencb.cellbase/cellbase-core

private boolean isPhased(Variant variant) {
  return (variant.getStudies() != null && !variant.getStudies().isEmpty())
    && variant.getStudies().get(0).getFormat().contains("PS");
}
origin: org.opencb.biodata/biodata-models

public StudyEntry addSampleData(Integer samplePosition, Integer formatIdx, String value, String defaultValue) {
  Consumer<List<String>> update = sampleData -> getSamplesData().set(samplePosition, sampleData);
  if (formatIdx != null && samplePosition != null) {
    List<String> sampleData = getSamplesData().get(samplePosition);
    if (sampleData == null) {
      sampleData = new ArrayList<>(getFormat().size());
      getSamplesData().set(samplePosition, sampleData);
    }
    if (formatIdx < sampleData.size()) {
      actOnList(sampleData, l -> l.set(formatIdx, value), update);
    } else {
      while (formatIdx > sampleData.size()) {
        sampleData = actOnList(sampleData, l -> l.add(defaultValue), update);
      }
      actOnList(sampleData, l -> l.add(value), update);
    }
  } else {
    throw new IndexOutOfBoundsException();
  }
  return this;
}
origin: opencb/opencga

private void fillEmptySamplesData(StudyEntry studyEntry, StudyConfiguration studyConfiguration, int fillMissingColumnValue) {
  List<String> format = studyEntry.getFormat();
  List<String> emptyData = new ArrayList<>(format.size());
  List<String> emptyDataReferenceGenotype = new ArrayList<>(format.size());
origin: org.opencb.cellbase/cellbase-core

private boolean samePhase(Variant variant1, Variant variant2) {
  if (variant1.getStudies() != null && !variant1.getStudies().isEmpty()) {
    if (variant2.getStudies() != null && !variant2.getStudies().isEmpty()) {
      int psIdx1 = variant1.getStudies().get(0).getFormat().indexOf("PS");
      if (psIdx1 != -1) {
        int psIdx2 = variant2.getStudies().get(0).getFormat().indexOf("PS");
        if (psIdx2 != -1 &&  // variant2 does have PS set
            // same phase set value in both variants
            variant2.getStudies().get(0).getSamplesData().get(0).get(psIdx2)
                .equals(variant1.getStudies().get(0).getSamplesData().get(0).get(psIdx1))
            // Same genotype call in both variants (e.g. 1|0=1|0).
            // WARNING: assuming variant1 and variant2 do have Files.
            && variant1.getStudies().get(0).getFiles().get(0).getCall()
            .equals(variant2.getStudies().get(0).getFiles().get(0).getCall())) {
          return true;
        }
      }
    }
  }
  return false;
}
origin: opencb/cellbase

private boolean samePhase(Variant variant1, Variant variant2) {
  if (variant1.getStudies() != null && !variant1.getStudies().isEmpty()) {
    if (variant2.getStudies() != null && !variant2.getStudies().isEmpty()) {
      int psIdx1 = variant1.getStudies().get(0).getFormat().indexOf("PS");
      if (psIdx1 != -1) {
        int psIdx2 = variant2.getStudies().get(0).getFormat().indexOf("PS");
        if (psIdx2 != -1 &&  // variant2 does have PS set
            // same phase set value in both variants
            variant2.getStudies().get(0).getSamplesData().get(0).get(psIdx2)
                .equals(variant1.getStudies().get(0).getSamplesData().get(0).get(psIdx1))
            // Same genotype call in both variants (e.g. 1|0=1|0).
            // WARNING: assuming variant1 and variant2 do have Files.
            && variant1.getStudies().get(0).getFiles().get(0).getCall()
            .equals(variant2.getStudies().get(0).getFiles().get(0).getCall())) {
          return true;
        }
      }
    }
  }
  return false;
}
origin: org.opencb.biodata/biodata-tools

String phaseSet = "";
for (String formatField : study.getFormat()) {
  String sampleData = study.getSampleData(sample, formatField);
  switch (formatField) {
origin: org.opencb.biodata/biodata-tools

List<Genotype> genotypes = getGenotypes(alleleList, studyEntry.getFormat(), getSampleData);
origin: opencb/opencga

@Test
public void testExcludeFiles() {
  for (String exclude : Arrays.asList("studies.files", "files")) {
    queryResult = query(new Query(), new QueryOptions(QueryOptions.EXCLUDE, exclude));
    assertEquals(allVariants.getResult().size(), queryResult.getResult().size());
    for (Variant variant : queryResult.getResult()) {
      assertThat(variant.getStudies().get(0).getFiles(), is(Collections.emptyList()));
      assertThat(new HashSet<>(variant.getStudies().get(0).getFormat()), is(FORMAT));
    }
  }
}
origin: org.opencb.biodata/biodata-tools

List<String> formatLst = decodeFormat(study.getFormat().stream().collect(Collectors.joining(","))); // FORMAT column
if (!isDefaultFormat(formatLst)) {
origin: opencb/opencga

@Test
public void testReturnNoneFiles() {
  queryResult = query(new Query(INCLUDE_FILE.key(), VariantQueryUtils.NONE), new QueryOptions());
  assertEquals(allVariants.getResult().size(), queryResult.getResult().size());
  for (Variant variant : queryResult.getResult()) {
    assertThat(variant.getStudies().get(0).getFiles(), is(Collections.emptyList()));
    assertThat(new HashSet<>(variant.getStudies().get(0).getFormat()), is(FORMAT));
  }
}
origin: opencb/opencga

  se.setSamplesPosition(new HashMap<>());
if (null != vse.getFormat()) {
  se.setFormat(new ArrayList<>(vse.getFormat()));
} else {
  se.setFormat(new ArrayList<>());
origin: opencb/opencga

studyEntry.setFormat(archiveVariant.getStudies().get(0).getFormat());
studyEntry.setSortedSamplesPosition(new LinkedHashMap<>());
studyEntry.setSamplesData(new ArrayList<>());
org.opencb.biodata.models.variantStudyEntrygetFormat

Javadoc

Do not modify this list

Popular methods of StudyEntry

  • getSamplesData
  • getFiles
  • <init>
  • getSampleData
  • getFile
  • getStudyId
  • getOrderedSamplesName
  • getSamplesName
  • setFiles
  • setFormat
  • setSamplesData
  • setSamplesPosition
  • setSamplesData,
  • setSamplesPosition,
  • getFormatPositions,
  • getStats,
  • setStats,
  • addSampleData,
  • getSamplesPosition,
  • getSecondaryAlternates,
  • setSecondaryAlternates

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • String (java.lang)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now