/**
* Computes and returns comma-delimited HGVS notation peptide variants derived
* from codon allele variants. If no variants are found, answers an empty
- * string.
+ * string. The peptide variant is either simply read from the "CSQ:HGVSp"
+ * attribute if present, else computed based on the "alleles" attribute if
+ * present. If neither attribute is found, no variant (empty string) is
+ * returned.
*
* @param sf
- * a sequence feature (which must be one of those held in this
- * object)
+ * a sequence feature (which must be one of those held in this
+ * object)
* @return
*/
public String findProteinVariants(SequenceFeature sf)
sb.append(String.format(ROW_DATA, "Location", name,
begin == end ? begin
: begin + (isContactFeature() ? ":" : "-") + end));
+
+ String consequence = "";
if (mf != null)
{
int[] beginRange = mf.getMappedPositions(begin, begin);
: from + (isContactFeature() ? ":" : "-") + to));
if (mf.isFromCds())
{
- sb.append(String.format(ROW_DATA, "Consequence",
- mf.findProteinVariants(this), "<i>imputed by Jalview</i>"));
+ consequence = mf.findProteinVariants(this);
}
}
sb.append(String.format(ROW_DATA, "Type", type, ""));
sb.append(String.format(ROW_DATA, "Group", featureGroup, ""));
}
+ if (!consequence.isEmpty())
+ {
+ sb.append(String.format(ROW_DATA, "Consequence",
+ "<i>Imputed by Jalview</i>", consequence));
+ }
+
if (otherDetails != null)
{
TreeMap<String, Object> ordered = new TreeMap<>(
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import java.util.ArrayList;
+import java.util.List;
+
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import jalview.gui.JvOptionPane;
+import jalview.util.MapList;
public class SequenceFeatureTest
{
+ "<tr><td>Group</td><td>Uniprot</td><td></td></tr></table>";
assertEquals(expected, sf.getDetailsReport(seqName, null));
}
+
+ /**
+ * Feature details report for a virtual feature should include original and
+ * mapped locations, and also derived peptide consequence if it can be
+ * determined
+ */
+ @Test(groups = { "Functional" })
+ public void testGetDetailsReport_virtualFeature()
+ {
+ SequenceI cds = new Sequence("Cds/101-121", "CCTttgAGAtttCAAatgGAT");
+ SequenceI seq = new Sequence("TestSeq/8-14", "PLRFQMD");
+ MapList map = new MapList(new int[] { 101, 118 }, new int[] { 8, 13 },
+ 3, 1);
+ Mapping mapping = new Mapping(seq.getDatasetSequence(), map);
+ List<SequenceFeature> features = new ArrayList<>();
+ // vary ttg (Leu) to ttc (Phe)
+ SequenceFeature sf = new SequenceFeature("variant", "G,C", 106, 106,
+ null);
+ sf.setValue("alleles", "G,C"); // needed to compute peptide consequence!
+ features.add(sf);
+
+ MappedFeatures mf = new MappedFeatures(mapping, cds, 9, 'L', features);
+
+ String expected = "<br><table><tr><td>Location</td><td>Cds</td><td>106</td></tr>"
+ + "<tr><td>Peptide Location</td><td>TestSeq</td><td>9</td></tr>"
+ + "<tr><td>Type</td><td>variant</td><td></td></tr>"
+ + "<tr><td>Description</td><td>G,C</td><td></td></tr>"
+ + "<tr><td>Consequence</td><td><i>Imputed by Jalview</i></td><td>p.Leu9Phe</td></tr>"
+ + "<tr><td>alleles</td><td></td><td>G,C</td></tr>"
+ + "</table>";
+
+ assertEquals(expected, sf.getDetailsReport(seq.getName(), mf));
+ }
}