Merge branch 'feature/JAL-3143ensemblJSON' into feature/JAL-3187linkedFeatures
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 20 Feb 2019 16:40:57 +0000 (16:40 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 20 Feb 2019 16:40:57 +0000 (16:40 +0000)
1  2 
src/jalview/analysis/AlignmentUtils.java
src/jalview/ext/ensembl/EnsemblSeqProxy.java

@@@ -74,12 -74,15 +74,15 @@@ import java.util.TreeMap
   */
  public class AlignmentUtils
  {
    private static final int CODON_LENGTH = 3;
  
    private static final String SEQUENCE_VARIANT = "sequence_variant:";
  
-   private static final String ID = "ID";
+   /*
+    * the 'id' attribute is provided for variant features fetched from
+    * Ensembl using its REST service with JSON format 
+    */
+   public static final String VARIANT_ID = "id";
  
    /**
     * A data model to hold the 'normal' base value at a position, and an optional
          SequenceI prot = mapping.findAlignedSequence(dnaSeq, protein);
          if (prot != null)
          {
 -          Mapping seqMap = mapping.getMappingForSequence(dnaSeq);
 +          Mapping seqMap = mapping.getMappingForSequence(dnaSeq, false);
            addCodonPositions(dnaSeq, prot, protein.getGapCharacter(), seqMap,
                    alignedCodons);
            unmappedProtein.remove(prot);
    static int computePeptideVariants(SequenceI peptide, int peptidePos,
            List<DnaVariant>[] codonVariants)
    {
 -    String residue = String.valueOf(peptide.getCharAt(peptidePos - 1));
 +    String residue = String
 +            .valueOf(peptide.getCharAt(peptidePos - peptide.getStart()));
      int count = 0;
      String base1 = codonVariants[0].get(0).base;
      String base2 = codonVariants[1].get(0).base;
              peptidePos, var.getSource());
  
      StringBuilder attributes = new StringBuilder(32);
-     String id = (String) var.variant.getValue(ID);
+     String id = (String) var.variant.getValue(VARIANT_ID);
      if (id != null)
      {
        if (id.startsWith(SEQUENCE_VARIANT))
        {
          id = id.substring(SEQUENCE_VARIANT.length());
        }
-       sf.setValue(ID, id);
-       attributes.append(ID).append("=").append(id);
+       sf.setValue(VARIANT_ID, id);
+       attributes.append(VARIANT_ID).append("=").append(id);
        // TODO handle other species variants JAL-2064
        StringBuilder link = new StringBuilder(32);
        try
@@@ -62,8 -62,6 +62,6 @@@ import org.json.simple.parser.ParseExce
   */
  public abstract class EnsemblSeqProxy extends EnsemblRestClient
  {
-   protected static final String NAME = "Name";
    protected static final String DESCRIPTION = "description";
  
    /*
           * copy exon features to protein, compute peptide variants from dna 
           * variants and add as features on the protein sequence ta-da
           */
 -        AlignmentUtils.computeProteinFeatures(querySeq, proteinSeq,
 -                mapList);
 +        // JAL-3187 render on the fly instead
 +        // AlignmentUtils.computeProteinFeatures(querySeq, proteinSeq, mapList);
        }
      } catch (Exception e)
      {
    protected boolean featureMayBelong(SequenceFeature sf, String identifier)
    {
      String parent = (String) sf.getValue(PARENT);
-     // using contains to allow for prefix "gene:", "transcript:" etc
      if (parent != null
-             && !parent.toUpperCase().contains(identifier.toUpperCase()))
+             && !parent.equalsIgnoreCase(identifier))
      {
        // this genomic feature belongs to a different transcript
        return false;
      return true;
    }
  
+   /**
+    * Answers a short description of the sequence fetcher
+    */
    @Override
    public String getDescription()
    {
  
    /**
     * Answers true if the feature type is either 'NMD_transcript_variant' or
-    * 'transcript' or one of its sub-types in the Sequence Ontology. This is
-    * needed because NMD_transcript_variant behaves like 'transcript' in Ensembl
+    * 'transcript' (or one of its sub-types in the Sequence Ontology). This is
+    * because NMD_transcript_variant behaves like 'transcript' in Ensembl
     * although strictly speaking it is not (it is a sub-type of
     * sequence_variant).
+    * <p>
+    * (This test was needed when fetching transcript features as GFF. As we are
+    * now fetching as JSON, all features have type 'transcript' so the check for
+    * NMD_transcript_variant is redundant. Left in for any future case arising.)
     * 
     * @param featureType
     * @return