Get the string GT for a sample, with validation checking @param rec record to extract the GT from @param sample the sample index @return the split GT field @throws NoTalkbackSlimException if the record does not contain GT values, or the sample is invalid.
(VcfRecord rec, int sample)
| 768 | * @throws NoTalkbackSlimException if the record does not contain GT values, or the sample is invalid. |
| 769 | */ |
| 770 | public static String getValidGtStr(VcfRecord rec, int sample) { |
| 771 | final List<String> gtList = rec.getFormat(FORMAT_GENOTYPE); |
| 772 | if (gtList == null) { |
| 773 | throw new VcfFormatException("VCF record does not contain GT field, record: " + rec.toString()); |
| 774 | } |
| 775 | if (sample >= gtList.size()) { |
| 776 | throw new VcfFormatException("Invalid sample number " + sample + ", record: " + rec.toString()); |
| 777 | } |
| 778 | return gtList.get(sample); |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * Check if the record contains a well-defined variant genotype for the specified sample. |
no test coverage detected