htsjdk.samtools.SAMRecordCoordinateComparator Java Examples

The following examples show how to use htsjdk.samtools.SAMRecordCoordinateComparator. 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: SmartSamWriter.java    From rtg-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Constructor
 * @param out where records should eventually be sent
 */
public SmartSamWriter(SAMFileWriter out) {
  super(BUFFER_SIZE, new SAMRecordCoordinateComparator() {
    @Override
    public int compare(final SAMRecord samRecord1, final SAMRecord samRecord2) {
      final int cmp = super.compare(samRecord1, samRecord2);
      if (cmp != 0) {
        return cmp;
      }
      final SAMReadGroupRecord rg1 = samRecord1.getReadGroup();
      final SAMReadGroupRecord rg2 = samRecord2.getReadGroup();
      if (rg1 == rg2) {
        return 0;
      }
      return rg1 == null ? -1 : rg2 == null ? 1 : rg1.getReadGroupId().compareTo(rg2.getReadGroupId());
    }
  });
  mOut = out;
}
 
Example #2
Source File: SVUtilsUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@DataProvider
private Object[][] forGetSamRecordComparator() {
    final List<Object[]> data = new ArrayList<>(2);
    data.add(new Object[]{SAMFileHeader.SortOrder.coordinate, SAMRecordCoordinateComparator.class});
    data.add(new Object[]{SAMFileHeader.SortOrder.queryname, SAMRecordQueryNameComparator.class});
    return data.toArray(new Object[data.size()][]);
}
 
Example #3
Source File: SortingSAMRecordCollection.java    From abra2 with MIT License 4 votes vote down vote up
public static SortingSAMRecordCollection newSortByCoordinateInstance(SAMRecord[] recordArray, SAMFileHeader header, int maxRecordsInRAM, String tempDir) {
	return new SortingSAMRecordCollection(recordArray, header, new SAMRecordCoordinateComparator(), maxRecordsInRAM, tempDir);
}