Provides routines for merging VCF records.
| 49 | * Provides routines for merging VCF records. |
| 50 | */ |
| 51 | public class VcfRecordMerger { |
| 52 | |
| 53 | /** Maximum number of duplicate warnings to explicitly print. */ |
| 54 | public static final long DUPLICATE_WARNINGS_TO_PRINT = 5; |
| 55 | |
| 56 | private long mMultipleRecordsForSampleCount = 0; |
| 57 | private String mDefaultFormat = VcfUtils.FORMAT_GENOTYPE; |
| 58 | private boolean mAllowRecordMerging = true; |
| 59 | private boolean mPaddingAware = true; |
| 60 | private boolean mDropUnmergeable; |
| 61 | private VcfHeader mHeader; |
| 62 | private Set<String> mUnmergeableFormatFields = Collections.emptySet(); |
| 63 | private Set<String> mUnmergeableInfoFields = Collections.emptySet(); |
| 64 | |
| 65 | |
| 66 | /** |
| 67 | * @param defaultFormat the ID of the FORMAT field to fall back to when merging sample-free VCFs with those containing samples |
| 68 | * @return this object, for call chaining |
| 69 | */ |
| 70 | public final VcfRecordMerger setDefaultFormat(String defaultFormat) { |
| 71 | mDefaultFormat = defaultFormat; |
| 72 | return this; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Sets whether we can attempt to merge multiple records at the same position (e.g. multiple samples). |
| 77 | * Note that other options may subsequent veto a multi-record merge in specific conditions. |
| 78 | * |
| 79 | * @param recordMerging if false, records at the same position will never be combined into a single record. |
| 80 | * @return this object, for call chaining |
| 81 | */ |
| 82 | public final VcfRecordMerger setAllowMerging(boolean recordMerging) { |
| 83 | mAllowRecordMerging = recordMerging; |
| 84 | return this; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Sets the behaviour when merging records containing padding bases with those without padding bases, |
| 89 | * to avoid semantic pollution of annotations. |
| 90 | * |
| 91 | * @param paddingAware if true, do not merge records containing padding bases with those without padding bases, |
| 92 | * if false, allow merging to proceed. |
| 93 | * @return this object, for call chaining |
| 94 | */ |
| 95 | public final VcfRecordMerger setPaddingAware(boolean paddingAware) { |
| 96 | mPaddingAware = paddingAware; |
| 97 | return this; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Sets the behaviour when encountering any non-mergeable FORMAT fields or duplicate records for the same sample. |
| 102 | * |
| 103 | * @param dropUnmergeable if false, non-mergeable fields will prevent merging. If true, non-mergeable fields |
| 104 | * will be dropped so the merge can continue. |
| 105 | * @return this object, for call chaining |
| 106 | */ |
| 107 | public VcfRecordMerger setDropUnmergeable(boolean dropUnmergeable) { |
| 108 | mDropUnmergeable = dropUnmergeable; |
nothing calls this directly
no outgoing calls
no test coverage detected