For IntelliJ IDEA and
Android Studio


private void myMethod () {SAMFileHeader s =
new SAMFileHeader()
SamReader samReader;samReader.getFileHeader()
- AI code suggestions by Codota
}
/** creates a independent copy of the given IntervalList * * @param list * @return */ public static IntervalList copyOf(final IntervalList list){ final IntervalList clone = new IntervalList(list.header.clone()); clone.intervals.addAll(list.intervals); return clone; }
/** Returns a new IntervalList where each interval is padded by the specified amount of bases. */ public IntervalList padded(final int before, final int after) { if (before < 0 || after < 0) throw new IllegalArgumentException("Padding values must be >= 0."); final IntervalList padded = new IntervalList(this.getHeader().clone()); final SAMSequenceDictionary dict = padded.getHeader().getSequenceDictionary(); for (final Interval i : this) { final SAMSequenceRecord seq = dict.getSequence(i.getContig()); final int start = Math.max(1, i.getStart() - before); final int end = Math.min(seq.getSequenceLength(), i.getEnd() + after); padded.add(new Interval(i.getContig(), start, end, i.isNegativeStrand(), i.getName())); } return padded; }
@Override public void initialize() { // All for the no_pg_tag. Should this be in the engine and not in the walker? final GenomeAnalysisEngine toolkit = getToolkit(); final SAMFileHeader outputHeader = toolkit.getSAMFileHeader().clone(); final String PROGRAM_RECORD_NAME = "GATK PrintReads"; final boolean preSorted = true; if (toolkit.getArguments().BQSR_RECAL_FILE != null && !NO_PG_TAG ) { NWaySAMFileWriter.setupWriter(out, toolkit, outputHeader, preSorted, this, PROGRAM_RECORD_NAME); } else { out.writeHeader(outputHeader); out.setPresorted(preSorted); } }
public void setHeader(final SAMFileHeader header) { this.header = header.clone(); }
public BetaPairValidatingRealignmentWriter(CompareToReference2 c2r, SAMFileWriter writer, String tempDir, int minInsertLen, int maxInsertLen) { this.writer = writer; this.c2r = c2r; header = writer.getFileHeader().clone(); header.setSortOrder(SortOrder.queryname); parser = new SAMLineParser(new DefaultSAMRecordFactory(), ValidationStringency.SILENT, header, null, null); candidatesSam = tempDir + "/candidates.bam"; candidatesSamWriter = new SAMFileWriterFactory().makeBAMWriter( header, false, new File(candidatesSam), 1); this.minInsertLength = minInsertLen; this.maxInsertLength = maxInsertLen; }
/** * Copy the CRAM header into a new {@link CramHeader} object. * @return a complete copy of the header */ @SuppressWarnings("CloneDoesntCallSuperClone") @Override public CramHeader clone() { final CramHeader clone = new CramHeader(); clone.version = version; System.arraycopy(id, 0, clone.id, 0, id.length); clone.samFileHeader = getSamFileHeader().clone(); return clone; }
/** * Creates a program record for the program, adds it to the list of program records (@PG tags) in the bam file and sets * up the writer with the header and presorted status. * * @param originalHeader original header * @param programRecord the program record for this program */ public static SAMFileHeader setupWriter(final SAMFileHeader originalHeader, final SAMProgramRecord programRecord) { final SAMFileHeader header = originalHeader.clone(); final List<SAMProgramRecord> oldRecords = header.getProgramRecords(); final List<SAMProgramRecord> newRecords = new ArrayList<SAMProgramRecord>(oldRecords.size()+1); for ( SAMProgramRecord record : oldRecords ) if ( (programRecord != null && !record.getId().startsWith(programRecord.getId()))) newRecords.add(record); if (programRecord != null) { newRecords.add(programRecord); header.setProgramRecords(newRecords); } return header; }
@Override protected int doWork() { IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE); IOUtil.assertFileIsWritable(OUTPUT); final ReferenceSequenceFile refFile = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE, true); if (!refFile.isIndexed()) { throw new IllegalStateException("Reference file must be indexed, but no index file was found"); } if (refFile.getSequenceDictionary() == null) { throw new IllegalStateException("Reference file must include a dictionary, but no dictionary file was found"); } // get the intervals final IntervalList intervals = segregateReference(refFile, MAX_TO_MERGE); log.info(String.format("Found %d intervals in %d loci during %s seconds", intervalProgress.getCount(), locusProgress.getCount(), locusProgress.getElapsedSeconds())); /********************************** * Now output regions for calling * **********************************/ final IntervalList outputIntervals = new IntervalList(intervals.getHeader().clone()); log.info(String.format("Collecting requested type of intervals (%s)", OUTPUT_TYPE)); intervals.getIntervals().stream().filter(i -> OUTPUT_TYPE.accepts(i.getName())).forEach(outputIntervals::add); log.info("Writing Intervals."); outputIntervals.write(OUTPUT); log.info(String.format("Execution ending. Total time %d seconds", locusProgress.getElapsedSeconds())); return 0; }
/** * A utility function for merging a list of IntervalLists, checks for equal dictionaries. * Merging does not look for overlapping intervals nor uniquify * * @param lists a list of IntervalList * @return the union of all the IntervalLists in lists. */ public static IntervalList concatenate(final Collection<IntervalList> lists) { if(lists.isEmpty()){ throw new SAMException("Cannot concatenate an empty list of IntervalLists."); } // Ensure that all the sequence dictionaries agree and merge the lists final SAMFileHeader header = lists.iterator().next().getHeader().clone(); header.setSortOrder(SAMFileHeader.SortOrder.unsorted); final IntervalList merged = new IntervalList(header); for (final IntervalList in : lists) { SequenceUtil.assertSequenceDictionariesEqual(merged.getHeader().getSequenceDictionary(), in.getHeader().getSequenceDictionary()); merged.addall(in.intervals); } return merged; }
/** * A utility function for generating the intersection of two IntervalLists, checks for equal dictionaries. * * @param list1 the first IntervalList * @param list2 the second IntervalList * @return the intersection of list1 and list2. */ public static IntervalList intersection(final IntervalList list1, final IntervalList list2) { final IntervalList result; // Ensure that all the sequence dictionaries agree and merge the lists SequenceUtil.assertSequenceDictionariesEqual(list1.getHeader().getSequenceDictionary(), list2.getHeader().getSequenceDictionary()); result = new IntervalList(list1.getHeader().clone()); final OverlapDetector<Interval> detector = new OverlapDetector<Interval>(0, 0); detector.addAll(list1.getIntervals(), list1.getIntervals()); for (final Interval i : list2.getIntervals()) { final Collection<Interval> as = detector.getOverlaps(i); for (final Interval j : as) { final Interval tmp = i.intersect(j); result.add(tmp); } } return result.uniqued(); }
/** * Returned an independent IntervalList that is sorted and uniquified. * @param concatenateNames If false, interval names are not concatenated when merging intervals to save space. */ public IntervalList uniqued(final boolean concatenateNames) { final List<Interval> tmp = getUniqueIntervals(sorted(), concatenateNames); final IntervalList value = new IntervalList(this.header.clone()); value.intervals.addAll(tmp); return value; }
/** * Copy the CRAM header into a new {@link CramHeader} object. * @return a complete copy of the header */ @SuppressWarnings("CloneDoesntCallSuperClone") @Override public CramHeader clone() { final CramHeader clone = new CramHeader(); clone.version = version; System.arraycopy(id, 0, clone.id, 0, id.length); clone.samFileHeader = getSamFileHeader().clone(); return clone; }
/** * Copy the CRAM header into a new {@link CramHeader} object. * @return a complete copy of the header */ @SuppressWarnings("CloneDoesntCallSuperClone") @Override public CramHeader clone() { final CramHeader clone = new CramHeader(); clone.version = version; System.arraycopy(id, 0, clone.id, 0, id.length); clone.samFileHeader = getSamFileHeader().clone(); return clone; }
@Override public void initialize() { // All for the no_pg_tag. Should this be in the engine and not in the walker? final GenomeAnalysisEngine toolkit = getToolkit(); final SAMFileHeader outputHeader = toolkit.getSAMFileHeader().clone(); final String PROGRAM_RECORD_NAME = "GATK PrintReads"; final boolean preSorted = true; if (toolkit.getArguments().BQSR_RECAL_FILE != null && !NO_PG_TAG ) { NWaySAMFileWriter.setupWriter(out, toolkit, outputHeader, preSorted, this, PROGRAM_RECORD_NAME); } else { out.writeHeader(outputHeader); out.setPresorted(preSorted); } }
/** * Creates a program record for the program, adds it to the list of program records (@PG tags) in the bam file and sets * up the writer with the header and presorted status. * * @param originalHeader original header * @param programRecord the program record for this program */ public static SAMFileHeader setupWriter(final SAMFileHeader originalHeader, final SAMProgramRecord programRecord) { final SAMFileHeader header = originalHeader.clone(); final List<SAMProgramRecord> oldRecords = header.getProgramRecords(); final List<SAMProgramRecord> newRecords = new ArrayList<SAMProgramRecord>(oldRecords.size()+1); for ( SAMProgramRecord record : oldRecords ) if ( (programRecord != null && !record.getId().startsWith(programRecord.getId()))) newRecords.add(record); if (programRecord != null) { newRecords.add(programRecord); header.setProgramRecords(newRecords); } return header; }