Java源码示例:htsjdk.samtools.util.Lazy

示例1
/**
 * Create a new PoN interface to a HDF5 file.
 *
 * <p>DEV NOTE:  If you are adding attributes that are not RealMatrix nor a primitive,
 * you must follow the pattern in the constructor (i.e. the Lazy loading pattern).
 * See the targetNames private attribute.  Otherwise, some operations will hang.</p>
 * @param file the underlying HDF5 file.
 * @throws IllegalArgumentException if {@code file} is {@code null}.
 */
public HDF5PCACoveragePoN(final HDF5File file) {
    Utils.nonNull(file, "The input file cannot be null.");
    this.file = file;
    targetNames = new Lazy<>(() -> readNames(file, TARGET_NAMES_PATH));
    rawTargetNames  = new Lazy<>(() -> readNames(file, RAW_TARGET_NAMES_PATH));
    panelTargetNames = new Lazy<>(() -> readNames(file, PANEL_TARGET_NAMES_PATH));
    targets  = new Lazy<>(() -> readTargets(file, TARGETS_PATH, TARGET_NAMES_PATH));
    rawTargets  = new Lazy<>(() -> readTargets(file, RAW_TARGETS_PATH, RAW_TARGET_NAMES_PATH));
    panelTargets = new Lazy<>(() -> readTargets(file, PANEL_TARGETS_PATH, PANEL_TARGET_NAMES_PATH));
    sampleNames = new Lazy<>(() -> readNames(file, SAMPLE_NAMES_PATH));
    panelSampleNames = new Lazy<>(() -> readNames(file, PANEL_SAMPLE_NAMES_PATH));
}
 
示例2
/**
 * DEV NOTE: If you are adding attributes that are neither RealMatrix nor a primitive,
 * you must follow the pattern in the constructor (i.e. the Lazy loading pattern).
 * Otherwise, some operations will hang.
 */
HDF5SimpleCountCollection(final HDF5File file) {
    Utils.nonNull(file);
    this.file = file;
    sampleName = new Lazy<>(() -> file.readStringArray(SAMPLE_NAME_PATH)[0]);
    sequenceDictionary = new Lazy<>(() -> {
        final String sequenceDictionaryString = file.readStringArray(SEQUENCE_DICTIONARY_PATH)[0];
        return new SAMTextHeaderCodec()
                .decode(BufferedLineReader.fromString(sequenceDictionaryString), file.getFile().getAbsolutePath())
                .getSequenceDictionary();
    });
    intervals = new Lazy<>(() -> HDF5Utils.readIntervals(file, INTERVALS_GROUP_NAME));
    counts = new Lazy<>(() -> new Array2DRowRealMatrix(file.readDoubleMatrix(COUNTS_PATH)));
}
 
示例3
/**
 * @param metadata records are sorted using the contained {@link SAMSequenceDictionary}
 */
AbstractLocatableCollection(final METADATA metadata,
                            final List<RECORD> records,
                            final TableColumnCollection mandatoryColumns,
                            final Function<DataLine, RECORD> recordFromDataLineDecoder,
                            final BiConsumer<RECORD, DataLine> recordToDataLineEncoder) {
    super(metadata, sortRecords(records, metadata.getSequenceDictionary()), mandatoryColumns, recordFromDataLineDecoder, recordToDataLineEncoder);
    CopyNumberArgumentValidationUtils.validateIntervals(getRecords(), metadata.getSequenceDictionary());
    this.overlapDetector = new Lazy<>(() -> OverlapDetector.create(getRecords()));
}
 
示例4
/**
 * @throws IllegalArgumentException if records are not sorted according to the {@link SAMSequenceDictionary} contained in the input file
 */
AbstractLocatableCollection(final File inputFile,
                            final TableColumnCollection mandatoryColumns,
                            final Function<DataLine, RECORD> recordFromDataLineDecoder,
                            final BiConsumer<RECORD, DataLine> recordToDataLineEncoder) {
    super(inputFile, mandatoryColumns, recordFromDataLineDecoder, recordToDataLineEncoder);
    CopyNumberArgumentValidationUtils.validateIntervals(getRecords(), getMetadata().getSequenceDictionary());
    this.overlapDetector = new Lazy<>(() -> OverlapDetector.create(getRecords()));
}
 
示例5
/**
 * DEV NOTE: If you are adding attributes that are neither RealMatrix nor a primitive,
 * you must follow the pattern in the constructor (i.e. the Lazy loading pattern).
 * Otherwise, some operations will hang.
 */
private HDF5SVDReadCountPanelOfNormals(final HDF5File file) {
    IOUtils.canReadFile(file.getFile());
    this.file = file;
    sequenceDictionary = new Lazy<>(() -> {
        final String sequenceDictionaryString = file.readStringArray(SEQUENCE_DICTIONARY_PATH)[0];
        return new SAMTextHeaderCodec()
                .decode(BufferedLineReader.fromString(sequenceDictionaryString), file.getFile().getAbsolutePath())
                .getSequenceDictionary();
    });
    originalIntervals = new Lazy<>(() -> HDF5Utils.readIntervals(file, ORIGINAL_INTERVALS_PATH));
    panelIntervals = new Lazy<>(() -> HDF5Utils.readIntervals(file, PANEL_INTERVALS_PATH));
}
 
示例6
private void setTargets(final List<Target> targets) {
    writeTargets(TARGETS_PATH, targets);
    this.targets  = new Lazy<>(() -> readTargets(file, TARGETS_PATH, TARGET_NAMES_PATH));
}
 
示例7
private void setRawTargets(final List<Target> targets) {
    writeTargets(RAW_TARGETS_PATH, targets);
    rawTargets = new Lazy<>(() -> readTargets(file, RAW_TARGETS_PATH, RAW_TARGET_NAMES_PATH));
}
 
示例8
private void setPanelTargets(final List<Target> targets) {
    writeTargets(PANEL_TARGETS_PATH, targets);
    panelTargets = new Lazy<>(() -> readTargets(file, PANEL_TARGETS_PATH, PANEL_TARGET_NAMES_PATH));
}
 
示例9
private void setTargetNames(final List<String> names) {
    writeNames(TARGET_NAMES_PATH, names);
    targetNames = new Lazy<>(() -> readNames(file, TARGET_NAMES_PATH));
}
 
示例10
private void setRawTargetNames(final List<String> names) {
    writeNames(RAW_TARGET_NAMES_PATH, names);
    rawTargetNames = new Lazy<>(() -> readNames(file, RAW_TARGET_NAMES_PATH));
}
 
示例11
private void setPanelTargetNames(final List<String> names) {
    writeNames(PANEL_TARGET_NAMES_PATH, names);
    panelTargetNames = new Lazy<>(() -> readNames(file, PANEL_TARGET_NAMES_PATH));
}
 
示例12
private void setSampleNames(final List<String> names) {
    writeNames(SAMPLE_NAMES_PATH, names);
    sampleNames = new Lazy<>(() -> readNames(file, SAMPLE_NAMES_PATH));
}
 
示例13
private void setPanelSampleNames(final List<String> names) {
    writeNames(PANEL_SAMPLE_NAMES_PATH, names);
    panelSampleNames = new Lazy<>(() -> readNames(file, PANEL_SAMPLE_NAMES_PATH));
}
 
示例14
/**
 * Constructor if the consumer wishes for the second-of-pair writer to be built on-the-fly.
 */
private FastqWriters(final FastqWriter firstOfPair, final Lazy<FastqWriter> secondOfPair, final FastqWriter unpaired) {
    this.firstOfPair = firstOfPair;
    this.unpaired = unpaired;
    this.secondOfPair = secondOfPair;
}
 
示例15
/**
 * Simple constructor; all writers are pre-initialized..
 */
private FastqWriters(final FastqWriter firstOfPair, final FastqWriter secondOfPair, final FastqWriter unpaired) {
    this(firstOfPair, new Lazy<>(() -> secondOfPair), unpaired);
}