Package htsjdk.variant.variantcontext

# Class VariantContextComparator

java.lang.Object
htsjdk.variant.variantcontext.VariantContextComparator

All Implemented Interfaces:
  `Serializable`, `Comparator<VariantContext>`

public class VariantContextComparator extends Object implements Comparator<VariantContext>, Serializable
A Comparator that orders VariantContexts by the ordering of the contigs/chromosomes in the List provided at construction time, then by start position with each contig/chromosome.

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`VariantContextComparator(SAMSequenceDictionary dictionary)`
`VariantContextComparator(Collection<VCFContigHeaderLine> headerLines)`
Creates a VariantContextComparator from the given VCF contig header lines.
`VariantContextComparator(List<String> contigs)`

## Method Summary

Modifier and Type
Method
Description
`int`
`compare(VariantContext firstVariantContext, VariantContext secondVariantContext)`
`static List<String>`
`getSequenceNameList(SAMSequenceDictionary dictionary)`
`boolean`
`isCompatible(Collection<VCFContigHeaderLine> headerLines)`
Returns true if the given header lines are from a file sorted according to this VariantContextComparator.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### VariantContextComparator

public VariantContextComparator(List<String> contigs)

### VariantContextComparator

public VariantContextComparator(Collection<VCFContigHeaderLine> headerLines)
Creates a VariantContextComparator from the given VCF contig header lines. The header lines' index values are used to order the contigs. Throws IllegalArgumentException if there are dupe

### VariantContextComparator

public VariantContextComparator(SAMSequenceDictionary dictionary)

## Method Details

### getSequenceNameList

public static List<String> getSequenceNameList(SAMSequenceDictionary dictionary)

### compare

public int compare(VariantContext firstVariantContext, VariantContext secondVariantContext)

Specified by:
  `compare` in interface `Comparator<VariantContext>`

### isCompatible

public boolean isCompatible(Collection<VCFContigHeaderLine> headerLines)
Returns true if the given header lines are from a file sorted according to this VariantContextComparator. For sorting to work properly, the contig in each header line must have the same index.