+ * Inspects CSQ data blocks (consequences) and adds attributes on the sequence
+ * feature for the current allele (and transcript if applicable)
+ * <p>
+ * Allele matching: we require field ALLELE_NUM to match altAlleleIndex. If
+ * the CSQ data does not include ALLELE_NUM values then no data is added to
+ * the variant feature.
+ * <p>
+ * 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).
+ *
+ * @param value
+ * @param seq
+ * @param sf
+ * @param altAlelleIndex
+ * (1=first alternative allele...)
+ */
+ protected void addConsequences(Object value, SequenceI seq,
+ SequenceFeature sf,
+ int altAlelleIndex)
+ {
+ if (!(value instanceof ArrayList<?>))
+ {
+ return;
+ }
+
+ List<String> consequences = (List<String>) value;
+
+ /*
+ * if CSQ data includes 'Feature', and any value matches the sequence name,
+ * then restrict consequence data to the matching value (transcript)
+ * i.e. just pick out consequences for the transcript the variant feature is on
+ */
+ String seqName = seq.getName()== null ? "" : seq.getName().toLowerCase();
+ boolean matchFeature = false;
+ String matchFeatureValue = null;
+ if (csqFeatureFieldIndex > -1)
+ {
+ for (String consequence : consequences)
+ {
+ String[] csqFields = consequence.split(PIPE_REGEX);
+ if (csqFields.length > csqFeatureFieldIndex)
+ {
+ String featureIdentifier = csqFields[csqFeatureFieldIndex];
+ if (featureIdentifier.length() > 4
+ && seqName.indexOf(featureIdentifier.toLowerCase()) > -1)
+ {
+ matchFeature = true;
+ matchFeatureValue = featureIdentifier;
+ }
+ }
+ }
+ }
+
+ StringBuilder sb = new StringBuilder(128);
+ boolean found = false;
+
+ for (String consequence : consequences)
+ {
+ String[] csqFields = consequence.split(PIPE_REGEX);
+
+ /*
+ * check consequence is for the current transcript
+ */
+ if (matchFeature)
+ {
+ if (csqFields.length <= csqFeatureFieldIndex)
+ {
+ continue;
+ }
+ String featureIdentifier = csqFields[csqFeatureFieldIndex];
+ if (!featureIdentifier.equals(matchFeatureValue))
+ {
+ continue; // consequence is for a different transcript
+ }
+ }
+
+ if (csqFields.length > csqAlleleNumberFieldIndex)
+ {
+ String alleleNum = csqFields[csqAlleleNumberFieldIndex];
+ if (String.valueOf(altAlelleIndex).equals(alleleNum))
+ {
+ if (found)
+ {
+ sb.append(COMMA);
+ }
+ found = true;
+ sb.append(consequence);
+ }
+ }
+ }
+
+ if (found)
+ {
+ sf.setValue(CSQ, sb.toString());
+ }
+ }
+
+ /**