sb.append(forwardStrand ? allele : Dna.reverseComplement(allele));
String alleles = sb.toString(); // e.g. G,A
- String type = getOntologyTerm(seq, variant, altAlleleIndex);
+ /*
+ * pick out the consequence data (if any) that is for the current allele
+ * and feature (transcript) that matches the current sequence
+ */
+ String consequence = getConsequenceForAlleleAndFeature(variant, CSQ_FIELD,
+ altAlleleIndex, csqAlleleFieldIndex,
+ csqAlleleNumberFieldIndex, seq.getName().toLowerCase(),
+ csqFeatureFieldIndex);
+
+ /*
+ * pick out the ontology term for the consequence type
+ */
+ String type = SequenceOntologyI.SEQUENCE_VARIANT;
+ if (consequence != null)
+ {
+ type = getOntologyTerm(seq, variant, altAlleleIndex,
+ consequence);
+ }
float score = getAlleleFrequency(variant, altAlleleIndex);
sf.setValue(Gff3Helper.ALLELES, alleles);
- addAlleleProperties(variant, seq, sf, altAlleleIndex);
+ addAlleleProperties(variant, seq, sf, altAlleleIndex, consequence);
seq.addSequenceFeature(sf);
* @param seq
* @param variant
* @param altAlleleIndex
+ * @param consequence
* @return
* @see http://www.sequenceontology.org/browser/current_svn/term/SO:0001060
*/
String getOntologyTerm(SequenceI seq, VariantContext variant,
- int altAlleleIndex)
+ int altAlleleIndex, String consequence)
{
String type = SequenceOntologyI.SEQUENCE_VARIANT;
* can we associate Consequence data with this allele and feature (transcript)?
* if so, prefer the consequence term from that data
*/
- String consequence = getConsequenceForAlleleAndFeature(variant,
- CSQ_FIELD,
- altAlleleIndex, csqAlleleFieldIndex, csqAlleleNumberFieldIndex,
- seq.getName().toLowerCase(), csqFeatureFieldIndex);
if (consequence != null)
{
String[] csqFields = consequence.split(PIPE_REGEX);
* @param sf
* @param altAlelleIndex
* (0, 1..)
+ * @param consequence
+ * if not null, the consequence specific to this sequence (transcript
+ * feature) and allele
*/
protected void addAlleleProperties(VariantContext variant, SequenceI seq,
- SequenceFeature sf, final int altAlelleIndex)
+ SequenceFeature sf, final int altAlelleIndex, String consequence)
{
Map<String, Object> atts = variant.getAttributes();
*/
if (CSQ_FIELD.equals(key))
{
- addConsequences(variant, seq, sf, altAlelleIndex);
+ addConsequences(variant, seq, sf, consequence);
continue;
}
/**
* Inspects CSQ data blocks (consequences) and adds attributes on the sequence
- * feature for the current allele (and transcript if applicable)
- * <p>
- * Allele matching: if field ALLELE_NUM is present, it must match
- * altAlleleIndex. If not present, then field Allele value must match the VCF
- * Allele.
+ * 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).
+ * If <code>myConsequence</code> 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 altAlleleIndex
- * (0, 1..)
+ * @param myConsequence
*/
protected void addConsequences(VariantContext variant, SequenceI seq,
- SequenceFeature sf, int altAlleleIndex)
+ SequenceFeature sf, String myConsequence)
{
- /*
- * first try to identify the matching consequence
- */
- String myConsequence = getConsequenceForAlleleAndFeature(variant,
- CSQ_FIELD, altAlleleIndex, csqAlleleFieldIndex,
- csqAlleleNumberFieldIndex, seq.getName().toLowerCase(),
- csqFeatureFieldIndex);
-
Object value = variant.getAttribute(CSQ_FIELD);
+ // TODO if CSQ not present, try ANN (for SnpEff consequence data)?
if (value == null || !(value instanceof List<?>))
{