Tabnine Logo
StudyEntry.getFormatPositions
Code IndexAdd Tabnine to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew ArrayList()
  • Codota Iconnew LinkedList()
  • Smart code suggestions by Tabnine
}
origin: org.opencb.biodata/biodata-models

public String getSampleData(String sampleName, String field) {
  requireSamplesPosition();
  if (samplesPosition.containsKey(sampleName)) {
    Map<String, Integer> formatPositions = getFormatPositions();
    if (formatPositions.containsKey(field)) {
      List<String> sampleData = impl.getSamplesData().get(samplesPosition.get(sampleName));
      Integer formatIdx = formatPositions.get(field);
      return  formatIdx < sampleData.size() ? sampleData.get(formatIdx) : null;
    }
  }
  return null;
}
origin: opencb/opencga

protected void addMainSampleDataColumn(StudyConfiguration studyConfiguration, StudyEntry studyEntry,
                    int[] formatsMap, Integer sampleId, List<String> sampleData) {
  sampleData = remapSamplesData(sampleData, formatsMap);
  Integer gtIdx = studyEntry.getFormatPositions().get("GT");
  // Replace UNKNOWN_GENOTYPE, if any
  if (gtIdx != null && GenotypeClass.UNKNOWN_GENOTYPE.equals(sampleData.get(gtIdx))) {
    sampleData.set(gtIdx, unknownGenotype);
  }
  String sampleName = studyConfiguration.getSampleIds().inverse().get(sampleId);
  studyEntry.addSampleData(sampleName, sampleData);
}
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: opencb/opencga

public static String extractGenotypeFilter(Variant a) {
  List<StudyEntry> studies = a.getStudies();
  if (studies.isEmpty()) {
    return null;
  }
  StudyEntry studyEntry = studies.get(0);
  List<List<String>> samplesData = studyEntry.getSamplesData();
  if (samplesData == null || samplesData.isEmpty()) {
    return null;
  }
  Integer keyPos = studyEntry.getFormatPositions().get(GENOTYPE_FILTER_KEY);
  if (null == keyPos) {
    return null;
  }
  List<String> sample = samplesData.get(0);
  if (sample.isEmpty()) {
    return null;
  }
  String af = sample.get(keyPos);
  return af;
}
origin: org.opencb.biodata/biodata-models

public StudyEntry addFormat(String value) {
  Map<String, Integer> formatPositions = getFormatPositions();
  if (formatPositions.containsKey(value)) {
    return this;
  } else {
    List<String> format = impl.getFormat();
    if (format == null) {
      format = new ArrayList<>(1);
      format.add(value);
      impl.setFormat(format);
    } else {
      actOnList(format, f -> f.add(value), impl::setFormat);
    }
    formatPositions.put(value, formatPositions.size());
  }
  return this;
}
origin: org.opencb.biodata/biodata-models

public StudyEntry addSampleData(String sampleName, String format, String value, String defaultValue) {
  requireSamplesPosition();
  Integer formatIdx = getFormatPositions().get(format);
  Integer samplePosition = getSamplesPosition().get(sampleName);
  return addSampleData(samplePosition, formatIdx, value, defaultValue);
}
origin: org.opencb.biodata/biodata-tools

private boolean filterSampleFormat(Variant variant, String formatKey, boolean mustPassAll, Predicate<String> valueValidator) {
  StudyEntry studyEntry = getStudyEntry(variant, datasetId);
  Integer idx = studyEntry.getFormatPositions().get(formatKey);
  if (idx == null || idx < 0) {
    return valueValidator.test(null);
  }
  if (mustPassAll) {
    for (List<String> data : studyEntry.getSamplesData()) {
      String value = data.get(idx);
      if (!valueValidator.test(value)) {
        return false;
      }
    }
    return true;
  } else {
    for (List<String> data : studyEntry.getSamplesData()) {
      String value = data.get(idx);
      if (valueValidator.test(value)) {
        return true;
      }
    }
    return false;
  }
}
origin: opencb/opencga

/**
 * A variant is RefVariant if all the samples have HomRef genotype (0, 0/0, 0|0, ...).
 * If the variant does not have genotype, or there is any genotype not homRef, the variant is not a RefVariant.
 * @param variant Variant to test
 * @return  True if the variant is a reference variant
 */
protected static boolean isRefVariant(Variant variant) {
  if (variant.getStudies().size() != 1) {
    throw new IllegalArgumentException("Required one Study per variant. Found " + variant.getStudies().size() + " studies instead");
  }
  StudyEntry studyEntry = variant.getStudies().get(0);
  Integer gtIdx = studyEntry.getFormatPositions().get("GT");
  if (gtIdx == null || gtIdx < 0) {
    return false;
  }
  for (List<String> data : studyEntry.getSamplesData()) {
    if (!isHomRef(data.get(gtIdx))) {
      return false;
    }
  }
  return true;
}
origin: org.opencb.biodata/biodata-tools

public static VariantStats calculate(Variant variant, StudyEntry study, Collection<String> sampleNames) {
  VariantStats variantStats = new VariantStats();
  Integer gtIdx = study.getFormatPositions().get("GT");
  LinkedHashMap<String, Integer> samplesPosition = study.getSamplesPosition();
origin: opencb/opencga

var.setType(NO_VARIATION);
StudyEntry se = var.getStudies().get(0);
Map<String, Integer> formatPositions = se.getFormatPositions();
int gtpos = formatPositions.get(GENOTYPE_KEY);
int filterPos = formatPositions.containsKey(GENOTYPE_FILTER_KEY)
origin: opencb/opencga

  public static Variant addGT(Variant var, String gt) {
    StudyEntry se = var.getStudy("1");
    se.addFormat("GT");
    se.getFormatPositions();
    se.setSamplesPosition(Collections.singletonMap("1", 0));
//        se.setFormat(Collections.singletonList("GT"));
    se.setSamplesData(Collections.singletonList(Collections.singletonList(gt)));
    return var;
  }

origin: opencb/opencga

public Put convert(Variant variant, Put put, Set<Integer> sampleIds, VariantOverlappingStatus overlappingStatus) {
  StudyEntry studyEntry = variant.getStudies().get(0);
  Integer gtIdx = studyEntry.getFormatPositions().get(VariantMerger.GT_KEY);
  int[] formatReMap = buildFormatRemap(studyEntry);
  int sampleIdx = 0;
origin: opencb/opencga

Integer gtIdx = studyEntry.getFormatPositions().get("GT");
if (gtIdx == null || gtIdx < 0) {
  throw new VariantQueryException("Missing GT at variant " + variant);
origin: opencb/opencga

if (studyEntry.getFormatPositions().containsKey("GT")) {
  int samplePosition = 0;
  Integer gtIdx = studyEntry.getFormatPositions().get("GT");
  for (String sampleName : studyEntry.getOrderedSamplesName()) {
    Integer sampleId = studyConfiguration.getSampleIds().get(sampleName);
origin: opencb/opencga

Integer gtIndex = studyEntry.getFormatPositions().get("GT");
for (Map.Entry<String, List<String>> entry : alternateFileIdMap.entrySet()) {
  String secondaryAlternates = entry.getKey();
origin: org.opencb.biodata/biodata-tools

public Variant convert(VcfSliceProtos.VcfRecord vcfRecord, String chromosome, int slicePosition) {
  int start = getStart(vcfRecord, slicePosition);
  int end = getEnd(vcfRecord, slicePosition);
  Variant variant = new Variant(chromosome, start, end, vcfRecord.getReference(), vcfRecord.getAlternate());
  variant.setType(getVariantType(vcfRecord.getType()));
  variant.setIds(vcfRecord.getIdNonDefaultList());
  variant.resetLength();
  FileEntry fileEntry = new FileEntry();
  fileEntry.setFileId(fileId);
  Map<String, String> attributes = getFileAttributes(vcfRecord);
  fileEntry.setAttributes(attributes);
  fileEntry.setCall(vcfRecord.getCall().isEmpty() ? null : vcfRecord.getCall());
  if (vcfRecord.getType().equals(VariantProto.VariantType.NO_VARIATION)) {
    attributes.put("END", Integer.toString(end));
  }
  StudyEntry studyEntry = new StudyEntry(studyId);
  studyEntry.setFiles(Collections.singletonList(fileEntry));
  studyEntry.setFormat(getFormat(vcfRecord));
  studyEntry.setSamplesData(getSamplesData(vcfRecord, studyEntry.getFormatPositions()));
  studyEntry.setSamplesPosition(retrieveSamplePosition());
  studyEntry.getFormatPositions(); // Initialize the map
  List<VariantProto.AlternateCoordinate> alts = vcfRecord.getSecondaryAlternatesList();
  studyEntry.setSecondaryAlternates(getAlternateCoordinates(alts));
  variant.addStudyEntry(studyEntry);
  studyEntry.getFormatPositions(); // Initialize the map
  return variant;
}
origin: org.opencb.biodata/biodata-tools

Integer gtIdx = study.getFormatPositions().get("GT");
LinkedHashMap<String, Integer> samplesPosition = study.getSamplesPosition();
origin: org.opencb.biodata/biodata-tools

recordBuilder.addAllSamples(encodeSamples(study.getFormatPositions(), format, study.getSamplesData()));
origin: opencb/opencga

if (variant != null && !variant.getStudies().isEmpty()) {
  StudyEntry studyEntry = variant.getStudies().get(0);
  Integer psIdx = studyEntry.getFormatPositions().get(VCFConstants.PHASE_SET_KEY);
  if (psIdx != null) {
    String ps = studyEntry.getSamplesData().get(0).get(psIdx);
origin: opencb/opencga

if (variant.getType().equals(VariantType.NO_VARIATION)) {
  StudyEntry study = variant.getStudies().get(0);
  Integer dpIdx = study.getFormatPositions().get("DP");
  if (dpIdx != null) {
    String dpStr = study.getSampleData(0).get(dpIdx);
org.opencb.biodata.models.variantStudyEntrygetFormatPositions

Popular methods of StudyEntry

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

Popular in Java

  • Creating JSON documents from java classes using gson
  • setContentView (Activity)
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Sublime Text for Python
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