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

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

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

origin: org.opencb.biodata/biodata-models

public void setFormatAsString(String format) {
  setFormat(Arrays.asList(format.split(":")));
}
origin: opencb/opencga

private void fillStudyEntryFields(StudyEntry study, LinkedHashMap<String, Integer> samplesPositionToReturn, List<String> extraFields,
      List<List<String>> samplesData, boolean excludeGenotypes) {
  if (study != null) {
    //Set FORMAT
    if (extraFields.isEmpty()) {
      if (excludeGenotypes) {
        study.setFormat(Collections.emptyList());
      } else {
        study.setFormat(Collections.singletonList("GT"));
      }
    } else {
      List<String> format = new ArrayList<>(1 + extraFields.size());
      if (!excludeGenotypes) {
        format.add("GT");
      }
      format.addAll(extraFields);
      study.setFormat(format);
    }
    //Set Samples Position
    study.setSamplesPosition(samplesPositionToReturn);
    //Set Samples Data
    study.setSamplesData(samplesData);
  }
}
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

protected StudyEntry newStudyEntry(StudyConfiguration studyConfiguration, List<String> fixedFormat) {
  StudyEntry studyEntry;
  if (studyNameAsStudyId) {
    studyEntry = new StudyEntry(studyConfiguration.getStudyName());
  } else {
    studyEntry = new StudyEntry(String.valueOf(studyConfiguration.getStudyId()));
  }
  if (expectedFormat == null) {
    studyEntry.setFormat(new ArrayList<>(fixedFormat));
  } else {
    studyEntry.setFormat(new ArrayList<>(expectedFormat));
  }
  LinkedHashMap<String, Integer> returnedSamplesPosition;
  if (mutableSamplesPosition) {
    returnedSamplesPosition = new LinkedHashMap<>(getReturnedSamplesPosition(studyConfiguration));
  } else {
    returnedSamplesPosition = getReturnedSamplesPosition(studyConfiguration);
  }
  studyEntry.setSamplesData(new ArrayList<>(returnedSamplesPosition.size()));
  studyEntry.setSortedSamplesPosition(returnedSamplesPosition);
  return studyEntry;
}
origin: org.opencb.biodata/biodata-tools

/**
 * @param n
 * @return studyEntryList
 */
public List<StudyEntry> getStudies(int n) {
  int studyID = 2;
  int fieldID = 3;
  List<StudyEntry> studyEntryList = new ArrayList<>();
  StudyEntry studyEntry = new StudyEntry();
  studyEntry.setStudyId(Integer.toString(studyID));
  studyEntry.setFileId(Integer.toString(fieldID));
  Map<String, String> attributes = genAttributes();
  studyEntry.setAttributes(attributes);
  studyEntry.setFormat(getFormat());
  List<List<String>> sampleList = new ArrayList<>(getFormat().size());
  for (int i = 0; i < n; i++) {
    sampleList.add(getRandomample());
  }
  studyEntry.setSamplesData(sampleList);
  studyEntryList.add(studyEntry);
  return studyEntryList;
}
origin: opencb/opencga

public static Variant addGTAndFilter(Variant var, String gt, String filter) {
  StudyEntry se = var.getStudy("1");
  se.setSamplesPosition(Collections.singletonMap("1", 0));
  se.setFormat(Arrays.asList(GENOTYPE_KEY, GENOTYPE_FILTER_KEY));
  se.setSamplesData(Collections.singletonList(Arrays.asList(gt, filter)));
  return var;
}
origin: org.opencb.biodata/biodata-tools

/**
 * Create an empty Variant (position, ref, alt) from a template with basic Study information without samples.
 * @param target Variant to take as a template
 * @return Variant filled with chromosome, start, end, ref, alt, study ID and format set to GT only, BUT no samples.
 */
public Variant createFromTemplate(Variant target) {
  Variant var = new Variant(target.getChromosome(), target.getStart(), target.getEnd(), target.getReference(), target.getAlternate());
  var.setType(target.getType());
  for(StudyEntry tse : target.getStudies()){
    StudyEntry se = new StudyEntry(tse.getStudyId());
    se.setFiles(Collections.singletonList(new FileEntry("", "", new HashMap<>())));
    se.setFormat(Arrays.asList(getGtKey(), getFilterKey()));
    se.setSamplesPosition(new HashMap<>());
    se.setSamplesData(new ArrayList<>());
    var.addStudyEntry(se);
  }
  return var;
}
origin: org.opencb.biodata/biodata-tools

currentStudy.setFormat(newFormat);
origin: opencb/opencga

public void writeVariant(MongoDBVariantStageConverterTask converterTask, MongoDBVariantStageLoader loader, String variantStr) {
  Variant variant = new Variant(variantStr);
  variant.setNames(Collections.emptyList());
  StudyEntry studyEntry = new StudyEntry("1", "1");
  studyEntry.setFormat(Collections.emptyList());
  variant.addStudyEntry(studyEntry);
  variantMap.put(variant.getChromosome(), variant);
  loader.write(converterTask.apply(Collections.singletonList(variant)));
}
origin: opencb/opencga

studyEntry.setFormat(Arrays.asList(stringToList.split(LIST_SEP)));
origin: opencb/opencga

StudyEntry se = new StudyEntry("0");
se.setSecondaryAlternates(getAlternateCoordinates(secondaryAlternates));
se.setFormat(studyEntry.getFormat());
se.setSamplesData(new ArrayList<>(fileIds.size()));
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-models

  studyEntry.setFiles(Collections.singletonList(fileEntry));
studyEntry.setFormat(format);
if (alternates.size() > 0) {
  List<AlternateCoordinate> secondaryAlternates = new ArrayList<>(alternates.size() - 1);
origin: opencb/opencga

  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<>());
origin: org.opencb.biodata/biodata-tools

studyEntry.setSamplesData(
    Collections.singletonList(Collections.singletonList(keyFields.getPhaseSet())));
studyEntry.setFormat(Collections.singletonList("PS"));
  normalizedEntry.setStudyId(entry.getStudyId());
  normalizedEntry.setSamplesPosition(entry.getSamplesPosition());
  normalizedEntry.setFormat(entry.getFormat());
origin: opencb/opencga

se.setFiles(Collections.singletonList(new FileEntry("1", "", new HashMap<>())));
v1.setStudies(Collections.singletonList(se));
se.setFormat(Arrays.asList(GENOTYPE_KEY, GENOTYPE_FILTER_KEY));
se.setSamplesPosition(asMap("S1", 0));
se.setSamplesData(Collections.singletonList(Arrays.asList("1/2", "LowGQXHetDel")));
v2.setStudies(Collections.singletonList(se));
se.setSamplesPosition(asMap("S1", 0));
se.setFormat(Arrays.asList(GENOTYPE_KEY, GENOTYPE_FILTER_KEY));
se.setSamplesData(Collections.singletonList(Arrays.asList("0/1", "PASS")));
addAttribute(v2, FILTER, "PASS");
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;
}
org.opencb.biodata.models.variantStudyEntrysetFormat

Popular methods of StudyEntry

  • getSamplesData
  • getFiles
  • <init>
  • getSampleData
  • getFile
  • getStudyId
  • getOrderedSamplesName
  • getSamplesName
  • setFiles
  • setSamplesData
  • setSamplesPosition
  • getFormat
    Do not modify this list
  • setSamplesPosition,
  • getFormat,
  • getFormatPositions,
  • getStats,
  • setStats,
  • addSampleData,
  • getSamplesPosition,
  • getSecondaryAlternates,
  • setSecondaryAlternates

Popular in Java

  • Start an intent from android
  • findViewById (Activity)
  • getSystemService (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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