SAMFileHeader.clone
Code IndexAdd Codota to your IDE (free)

Best code snippets using htsjdk.samtools.SAMFileHeader.clone(Showing top 15 results out of 315)

  • Common ways to obtain SAMFileHeader
private void myMethod () {
SAMFileHeader s =
  • new SAMFileHeader()
  • SamReader samReader;samReader.getFileHeader()
  • AI code suggestions by Codota
}
origin: com.github.samtools/htsjdk

/** 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;
}
origin: com.github.samtools/htsjdk

/** 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;
}
origin: broadgsa/gatk

@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);
  }
}
origin: com.github.samtools/htsjdk

public void setHeader(final SAMFileHeader header) {
  this.header = header.clone();
}
origin: mozack/abra

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;
}

origin: com.github.samtools/htsjdk

/**
 * 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;
}
origin: broadgsa/gatk-protected

/**
 * 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;
}
origin: com.github.broadinstitute/picard

@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;
}
origin: com.github.samtools/htsjdk

/**
 * 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;
}
origin: com.github.samtools/htsjdk

/**
 * 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();
}
origin: com.github.samtools/htsjdk

/**
 * 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;
}
origin: com.github.samtools/htsjdk

/**
 * 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;
}
origin: com.github.samtools/htsjdk

/**
 * 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;
}
origin: broadgsa/gatk-protected

@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);
  }
}
origin: broadgsa/gatk

/**
 * 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;
}
htsjdk.samtoolsSAMFileHeaderclone

Popular methods of SAMFileHeader

  • getSequenceDictionary
  • <init>
    Constructor that initializes the sequence dictionary with the provided one.
  • getReadGroups
  • setSortOrder
  • getProgramRecords
  • setSequenceDictionary
    Replace entire sequence dictionary. The given sequence dictionary is stored, not copied.
  • addReadGroup
  • getSequence
    Look up sequence record by name.
  • setReadGroups
    Replace entire list of read groups. The given list is stored, not copied.
  • getSortOrder
  • getReadGroup
    Look up read group record by name.
  • setProgramRecords
    Replace entire list of program records
  • getReadGroup,
  • setProgramRecords,
  • addProgramRecord,
  • addSequence,
  • getAttributes,
  • getSequenceIndex,
  • setAttribute,
  • addComment,
  • getAttribute

Popular classes and methods

  • getExternalFilesDir (Context)
  • findViewById (Activity)
  • setScale (BigDecimal)
    Returns a new BigDecimal instance with the specified scale. If the new scale is greater than the old
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Socket (java.net)
    Provides a client-side TCP socket.
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • TreeMap (java.util)
    A map whose entries are sorted by their keys. All optional operations such as #put and #remove are s
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)