X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fvcf%2FVCFLoader.java;h=9d98b7e6c675c2967424790c4f22e77c86161df1;hb=b87ae5ac68939a1b964682046e8b07958fae219a;hp=2847bd796157aa3ff9d207ced225c6a2f3c2ea43;hpb=f8b17a9e7363b8a9e7cd12d61bc6d611c7c97d7d;p=jalview.git diff --git a/src/jalview/io/vcf/VCFLoader.java b/src/jalview/io/vcf/VCFLoader.java index 2847bd7..9d98b7e 100644 --- a/src/jalview/io/vcf/VCFLoader.java +++ b/src/jalview/io/vcf/VCFLoader.java @@ -30,6 +30,9 @@ import java.util.Map.Entry; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import htsjdk.samtools.SAMException; +import htsjdk.samtools.SAMSequenceDictionary; +import htsjdk.samtools.SAMSequenceRecord; import htsjdk.samtools.util.CloseableIterator; import htsjdk.variant.variantcontext.Allele; import htsjdk.variant.variantcontext.VariantContext; @@ -47,6 +50,35 @@ import htsjdk.variant.vcf.VCFInfoHeaderLine; */ public class VCFLoader { + /** + * A class to model the mapping from sequence to VCF coordinates. Cases include + *
- * Allele matching: if field ALLELE_NUM is present, it must match - * altAlleleIndex. If not present, then field Allele value must match the VCF - * Allele. - *
- * Transcript matching: if sequence name can be identified to at least one of
- * the consequences' Feature values, then select only consequences that match
- * the value (i.e. consequences for the current transcript sequence). If not,
- * take all consequences (this is the case when adding features to the gene
- * sequence).
+ * If
- * If consequence data includes the ALLELE_NUM field, then this has to match
- * altAlleleIndex. Otherwise the Allele field of the consequence data has to
- * match the allele value.
- *
- * Optionally (if matchFeature is not null), restrict to only include
- * consequences whose Feature value matches. This allows us to attach
- * consequences to their respective transcripts.
- *
- * @param csqFields
- * @param matchFeature
- * @param variant
- * @param altAlelleIndex
- * (0, 1..)
- * @return
- */
- protected boolean includeConsequence(String[] csqFields,
- String matchFeature, VariantContext variant, int altAlelleIndex)
- {
- /*
- * check consequence is for the current transcript
- */
- if (matchFeature != null)
- {
- if (csqFields.length <= csqFeatureFieldIndex)
- {
- return false;
- }
- String featureIdentifier = csqFields[csqFeatureFieldIndex];
- if (!featureIdentifier.equals(matchFeature))
- {
- return false; // consequence is for a different transcript
- }
- }
-
- /*
- * if ALLELE_NUM is present, it must match altAlleleIndex
- * NB first alternate allele is 1 for ALLELE_NUM, 0 for altAlleleIndex
- */
- if (csqAlleleNumberFieldIndex > -1)
- {
- if (csqFields.length <= csqAlleleNumberFieldIndex)
- {
- return false;
- }
- String alleleNum = csqFields[csqAlleleNumberFieldIndex];
- return String.valueOf(altAlelleIndex + 1).equals(alleleNum);
- }
-
- /*
- * else consequence allele must match variant allele
- */
- if (csqAlleleFieldIndex > -1 && csqFields.length > csqAlleleFieldIndex)
- {
- String csqAllele = csqFields[csqAlleleFieldIndex];
- String vcfAllele = variant.getAlternateAllele(altAlelleIndex)
- .getBaseString();
- return csqAllele.equals(vcfAllele);
- }
-
- return false;
- }
-
- /**
* A convenience method to complement a dna base and return the string value
* of its complement
*
myConsequence
is not null, then this is the specific
+ * consequence data (pipe-delimited fields) that is for the current allele and
+ * transcript (sequence) being processed)
*
* @param variant
* @param seq
* @param sf
- * @param altAlelleIndex
- * (0, 1..)
+ * @param myConsequence
*/
protected void addConsequences(VariantContext variant, SequenceI seq,
- SequenceFeature sf, int altAlelleIndex)
+ SequenceFeature sf, String myConsequence)
{
Object value = variant.getAttribute(CSQ_FIELD);
+ // TODO if CSQ not present, try ANN (for SnpEff consequence data)?
- if (value == null || !(value instanceof ArrayList>))
+ if (value == null || !(value instanceof List>))
{
return;
}
@@ -888,42 +1227,17 @@ public class VCFLoader
List