import jalview.io.StructureFile;
import jalview.schemes.ResidueProperties;
import jalview.structure.StructureMapping;
+import jalview.util.Comparison;
import jalview.util.DBRefUtils;
import jalview.util.Format;
import jalview.xml.binding.sifts.Entry;
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);
String pdbFile, String chain) throws SiftsException
{
structId = (chain == null) ? pdbId : pdbId + "|" + chain;
- System.out.println("Getting mapping for: " + pdbId + "|" + chain
- + " : seq- " + seq.getName());
+ System.out.println("Getting SIFTS mapping for " + structId + ": seq "
+ + seq.getName());
final StringBuilder mappingDetails = new StringBuilder(128);
PrintStream ps = new PrintStream(System.out)
int pdbStart = UNASSIGNED;
int pdbEnd = UNASSIGNED;
- Integer[] keys = mapping.keySet().toArray(new Integer[0]);
- Arrays.sort(keys);
- if (keys.length < 1)
+ if (mapping.isEmpty())
{
- throw new SiftsException(">>> Empty SIFTS mapping generated!!");
+ throw new SiftsException("SIFTS mapping failed");
}
+
+ Integer[] keys = mapping.keySet().toArray(new Integer[0]);
+ Arrays.sort(keys);
seqStart = keys[0];
seqEnd = keys[keys.length - 1];
if (os != null)
{
MappingOutputPojo mop = new MappingOutputPojo();
- mop.setSeqStart(pdbStart);
- mop.setSeqEnd(pdbEnd);
+ mop.setSeqStart(seqStart);
+ mop.setSeqEnd(seqEnd);
mop.setSeqName(seq.getName());
mop.setSeqResidue(matchedSeq);
- mop.setStrStart(seqStart);
- mop.setStrEnd(seqEnd);
+ mop.setStrStart(pdbStart);
+ mop.setStrEnd(pdbEnd);
mop.setStrName(structId);
mop.setStrResidue(targetStrucSeqs.toString());
if (sPojo[0].entityId != null)
{
+ if (sPojo[0].pid < 1)
+ {
+ return null;
+ }
for (Entity entity : entities)
{
if (!entity.getEntityId().equalsIgnoreCase(sPojo[0].entityId))
{
if ((i + (j * len)) < seqRes.length())
{
- if (seqRes.charAt(i + (j * len)) == strRes
- .charAt(i + (j * len))
+ boolean sameChar = Comparison.isSameResidue(
+ seqRes.charAt(i + (j * len)),
+ strRes.charAt(i + (j * len)), false);
+ if (sameChar
&& !jalview.util.Comparison.isGap(seqRes.charAt(i
+ (j * len))))
{
return siftsEntry.getDbVersion();
}
+ public static void setMockSiftsFile(File file)
+ {
+ mockSiftsFile = file;
+ }
+
}