import jalview.util.Comparison;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
+import jalview.util.RangeComparator;
import java.io.IOException;
import java.net.MalformedURLException;
}
/**
- * 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 });
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;
+ }
+
}