org.broadinstitute.barclay.utils.Utils Java Examples
The following examples show how to use
org.broadinstitute.barclay.utils.Utils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertyUtils.java From picard with MIT License | 6 votes |
/** * Attempt to load a Properties object from an on-disk properties file. * @param propertyFilePath name of the properties file to load. Must have a .properties extension * @param clazz class used to obtain a class loader to use to locate the properties file * @return null if the files doesn't exist or isn't readable, otherwise a Properties object */ public static Properties loadPropertiesFile(final String propertyFilePath, final Class<?> clazz) { Utils.nonNull(propertyFilePath); try (final InputStream inputStream = clazz.getClassLoader().getResourceAsStream(propertyFilePath)) { if (inputStream != null) { final Properties properties = new Properties(); properties.load(inputStream); return properties; } else { return null; } } catch (IOException ex) { throw new RuntimeException(String.format("IOException loading properties file %s", propertyFilePath), ex); } }
Example #2
Source File: SimpleAnnotatedIntervalWriter.java From gatk with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @param annotatedIntervalHeader Header to write. Recommended to create the header using * {@link AnnotatedIntervalCodec#createHeaderForWriter(Path, List, SAMFileHeader)} or one of its overloaded * versions. Never {@code null} */ @Override public void writeHeader(final AnnotatedIntervalHeader annotatedIntervalHeader) { Utils.nonNull(annotatedIntervalHeader); if (!hasHeaderBeenWritten) { final String contigColumnName = annotatedIntervalHeader.getContigColumnName(); final String startColumnName = annotatedIntervalHeader.getStartColumnName(); final String endColumnName = annotatedIntervalHeader.getEndColumnName(); initializeForWriting(contigColumnName, startColumnName, endColumnName, annotatedIntervalHeader.getAnnotations()); try { final SAMFileHeader samFileHeader = annotatedIntervalHeader.getSamFileHeader(); if (samFileHeader != null) { fileWriter.write(samFileHeader.getSAMString()); } writer.writeHeaderIfApplies(); hasHeaderBeenWritten = true; } catch (final IOException e) { throw new UserException.CouldNotCreateOutputFile("Could not write to file.", e); } } else { logger.warn("Attempted to write header more than once. Ignoring this request."); } }
Example #3
Source File: CalledLegacySegmentCollection.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void write(final File outputFile) { Utils.nonNull(outputFile); try (final RecordCollectionWriter writer = new RecordCollectionWriter(new FileWriter(outputFile))) { writer.writeAllRecords(getRecords()); } catch (final IOException e) { throw new UserException.CouldNotCreateOutputFile(outputFile, e); } }
Example #4
Source File: VcfFuncotationMetadata.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param vcfInfoHeaderLines Never {@code null} * @return Metadata corresponding to VCF info fields. Never {@code null} */ public static VcfFuncotationMetadata create(final List<VCFInfoHeaderLine> vcfInfoHeaderLines) { Utils.nonNull(vcfInfoHeaderLines); return new VcfFuncotationMetadata( vcfInfoHeaderLines.stream().collect(Collectors.toMap(v -> v.getID(), Function.identity(), (x1,x2) -> x2, LinkedHashMap::new )) ); }
Example #5
Source File: DataSourceFuncotationFactory.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates a {@link List} of {@link Funcotation} for the given {@code variant}, {@code referenceContext}, {@code featureContext}, and {@code gencodeFuncotations}. * For some Data Sources knowledge of Gene Name or Transcript ID is required for annotation. * Accounts for override values passed into the constructor as well. * @param variant {@link VariantContext} to annotate. Never {@code null}. * @param referenceContext {@link ReferenceContext} corresponding to the given {@code variant}. Never {@code null}. * @param featureContext {@link FeatureContext} corresponding to the variant. Never {@code null}. * @param gencodeFuncotations {@link List} of {@link GencodeFuncotation} that have already been created for the given {@code variant}/{@code referenceContext}/{@code featureContext}. * {@code null} is acceptable if there are no corresponding gencode funcotations. * @return {@link List} of {@link Funcotation} given the {@code variant}, {@code referenceContext}, and {@code featureContext}. This should never be empty. */ public List<Funcotation> createFuncotations(final VariantContext variant, final ReferenceContext referenceContext, final FeatureContext featureContext, final List<GencodeFuncotation> gencodeFuncotations) { Utils.nonNull(variant); Utils.nonNull(referenceContext); Utils.nonNull(featureContext); final List<Funcotation> outputFuncotations; // Query this funcotation factory to get the list of overlapping features. // NOTE: This will only get features that are LOCATABLE! // This corresponds to requiresFeatures() returning `True`. final List<Feature> featureList = getFeaturesFromFeatureContext(featureContext); // If our featureList is compatible with this DataSourceFuncotationFactory, then we make our funcotations: if ( isFeatureListCompatible(featureList) ) { outputFuncotations = determineFuncotations(variant, referenceContext, featureList, gencodeFuncotations); // Set our overrides: setOverrideValuesInFuncotations(outputFuncotations); } else { return createDefaultFuncotationsOnVariant(variant, referenceContext); } if ((outputFuncotations == null) || (outputFuncotations.size() == 0)) { return createDefaultFuncotationsOnVariant(variant, referenceContext); } else { return outputFuncotations; } }
Example #6
Source File: XHMMEmissionProbabilityCalculator.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 4 votes |
public double generateRandomZScoreData(final double copyRatio) { Utils.nonNull(rng, "Random z-score sampling is called by the random number generator is null. This" + " instance of the class can not produce random samples."); return getEmissionMean(copyRatio) + rng.nextGaussian() * emissionStandardDeviation; }
Example #7
Source File: IntegerCopyNumberReferenceStateFactory.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 4 votes |
public IntegerCopyNumberReferenceStateFactory(@Nonnull final GermlinePloidyAnnotatedTargetCollection germlinePloidyAnnotatedTargetCollection) { this.germlinePloidyAnnotatedTargetCollection = Utils.nonNull(germlinePloidyAnnotatedTargetCollection); }