Merge branch 'develop' into features/JAL-2295setChimeraAttributes
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Dec 2016 09:47:55 +0000 (09:47 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Dec 2016 09:47:55 +0000 (09:47 +0000)
1  2 
src/jalview/ext/ensembl/EnsemblSeqProxy.java
src/jalview/ws/sifts/SiftsClient.java

@@@ -38,7 -38,6 +38,7 @@@ import jalview.io.gff.SequenceOntologyI
  import jalview.util.Comparison;
  import jalview.util.DBRefUtils;
  import jalview.util.MapList;
 +import jalview.util.RangeComparator;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
@@@ -111,6 -110,26 +111,6 @@@ public abstract class EnsemblSeqProxy e
    }
  
    /**
 -   * A comparator to sort ranges into ascending start position order
 -   */
 -  private class RangeSorter implements Comparator<int[]>
 -  {
 -    boolean forwards;
 -
 -    RangeSorter(boolean forward)
 -    {
 -      forwards = forward;
 -    }
 -
 -    @Override
 -    public int compare(int[] o1, int[] o2)
 -    {
 -      return (forwards ? 1 : -1) * Integer.compare(o1[0], o2[0]);
 -    }
 -
 -  }
 -
 -  /**
     * Default constructor (to use rest.ensembl.org)
     */
    public EnsemblSeqProxy()
        EnsemblFeatureType[] features = getFeaturesToFetch();
        AlignmentI geneFeatures = gffFetcher.getSequenceRecords(accId,
                features);
-       if (geneFeatures.getHeight() > 0)
+       if (geneFeatures != null && geneFeatures.getHeight() > 0)
        {
          genomicSequence = geneFeatures.getSequenceAt(0);
        }
       * a final sort is needed since Ensembl returns CDS sorted within source
       * (havana / ensembl_havana)
       */
 -    Collections.sort(regions, new RangeSorter(direction == 1));
 +    Collections.sort(regions, new RangeComparator(direction == 1));
  
      List<int[]> to = Arrays.asList(new int[] { start,
          start + mappedLength - 1 });
@@@ -74,12 -74,6 +74,12 @@@ import MCview.PDBChain
  
  public class SiftsClient implements SiftsClientI
  {
 +  /*
 +   * for use in mocking out file fetch for tests only
 +   * - reset to null after testing!
 +   */
 +  private static File mockSiftsFile;
 +
    private Entry siftsEntry;
  
    private StructureFile pdb;
     */
    public static File getSiftsFile(String pdbId) throws SiftsException
    {
 +    /*
 +     * return mocked file if it has been set
 +     */
 +    if (mockSiftsFile != null)
 +    {
 +      return mockSiftsFile;
 +    }
 +
      String siftsFileName = SiftsSettings.getSiftDownloadDirectory()
              + pdbId.toLowerCase() + ".xml.gz";
      File siftsFile = new File(siftsFileName);
            return new File(siftsFileName);
          }
        }
+       else
+       {
+         return siftsFile;
+       }
      }
      try
      {
      return siftsEntry.getDbVersion();
    }
  
 +  public static void setMockSiftsFile(File file)
 +  {
 +    mockSiftsFile = file;
 +  }
 +
  }