Holds information about a single variant that has not yet been oriented in a haplotype. A Variant can be asked for alleles using original GT-style allele IDs, including -1 for missing value.
| 48 | * A Variant can be asked for alleles using original GT-style allele IDs, including -1 for missing value. |
| 49 | */ |
| 50 | public class Variant implements Comparable<Variant>, VariantId { |
| 51 | |
| 52 | static final SequenceNameLocusComparator NATURAL_COMPARATOR = new SequenceNameLocusComparator(); |
| 53 | static final Comparator<VariantId> ID_COMPARATOR = new Comparator<VariantId>() { |
| 54 | @Override |
| 55 | public int compare(VariantId o1, VariantId o2) { |
| 56 | return Integer.compare(o1.getId(), o2.getId()); |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | private SequenceNameLocus mLocus; |
| 61 | private final int mId; |
| 62 | private final Allele[] mAlleles; |
| 63 | private final boolean mPhased; |
| 64 | private byte mStatus = 0; |
| 65 | |
| 66 | /** |
| 67 | * Construct the variant |
| 68 | * @param id the ID of the variant when read from the original input |
| 69 | * @param seq chromosome name |
| 70 | * @param alleles array of alleles where each entry corresponds to the allele for GT ID + 1 |
| 71 | * @param phased true if the variant call was phased |
| 72 | */ |
| 73 | public Variant(int id, String seq, Allele[] alleles, boolean phased) { |
| 74 | this(id, seq, Allele.getAlleleBounds(alleles), alleles, phased); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Construct the variant |
| 79 | * @param id the ID of the variant when read from the original input |
| 80 | * @param seq chromosome name |
| 81 | * @param bounds bounds of the alleles |
| 82 | * @param alleles array of alleles where each entry corresponds to the allele for GT ID + 1 |
| 83 | * @param phased true if the variant call was phased |
| 84 | */ |
| 85 | private Variant(int id, String seq, Range bounds, Allele[] alleles, boolean phased) { |
| 86 | //super(seq, bounds.getStart(), bounds.getEnd()); |
| 87 | mLocus = new SequenceNameLocusSimple(seq, bounds.getStart(), bounds.getEnd()); |
| 88 | mId = id; |
| 89 | mPhased = phased; |
| 90 | mAlleles = alleles; |
| 91 | } |
| 92 | |
| 93 | void trimAlleles() { |
| 94 | trimAlleles(true); |
| 95 | } |
| 96 | |
| 97 | void trimAlleles(boolean leftFirst) { |
| 98 | // Element 0 is missing value token |
| 99 | final byte[] ref = mAlleles[1].nt(); |
| 100 | mAlleles[1] = null; |
| 101 | for (int i = 2; i < mAlleles.length; i++) { |
| 102 | final Allele a = mAlleles[i]; |
| 103 | if (a != null && !a.unknown()) { |
| 104 | final byte[] alt = a.nt(); |
| 105 | final int stripLeading; |
| 106 | final int stripTrailing; |
| 107 | if (leftFirst) { |
nothing calls this directly
no outgoing calls
no test coverage detected