Merge branch 'develop' of https://source.jalview.org/git/jalview into develop
[jalview.git] / src / jalview / ws / sifts / SiftsClient.java
index 50cf5cb..e04bbb7 100644 (file)
@@ -26,6 +26,7 @@ import jalview.api.SiftsClientI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
+import jalview.io.StructureFile;
 import jalview.schemes.ResidueProperties;
 import jalview.structure.StructureMapping;
 import jalview.util.Format;
@@ -77,7 +78,7 @@ public class SiftsClient implements SiftsClientI
 {
   private Entry siftsEntry;
 
-  private PDBfile pdb;
+  private StructureFile pdb;
 
   private String pdbId;
 
@@ -147,10 +148,10 @@ public class SiftsClient implements SiftsClientI
    * @param pdbId
    * @throws SiftsException
    */
-  public SiftsClient(PDBfile pdb) throws SiftsException
+  public SiftsClient(StructureFile pdb) throws SiftsException
   {
     this.pdb = pdb;
-    this.pdbId = pdb.id;
+    this.pdbId = pdb.getId();
     File siftsFile = getSiftsFile(pdbId);
     siftsEntry = parseSIFTs(siftsFile);
   }
@@ -167,7 +168,7 @@ public class SiftsClient implements SiftsClientI
   public SiftsClient(PDBfile pdb, File siftsFile) throws SiftsException
   {
     this.pdb = pdb;
-    this.pdbId = pdb.id;
+    this.pdbId = pdb.getId();
     siftsEntry = parseSIFTs(siftsFile);
   }
 
@@ -456,7 +457,7 @@ public class SiftsClient implements SiftsClientI
   {
     ArrayList<Integer> omitNonObserved = new ArrayList<Integer>();
     int nonObservedShiftIndex = 0;
-    System.out.println("Generating mappings for : " + entityId);
+    // System.out.println("Generating mappings for : " + entityId);
     Entity entity = null;
     entity = getEntityById(entityId);
     String originalSeq = AlignSeq.extractGaps(
@@ -491,8 +492,8 @@ public class SiftsClient implements SiftsClientI
     for (Segment segment : segments)
     {
       segStartEnd = segment.getStart() + " - " + segment.getEnd();
-      System.out.println("Mappging segments : " + segment.getSegId() + "\\"
-              + segStartEnd);
+      // System.out.println("Mapping segments : " + segment.getSegId() + "\\"
+      // + segStartEnd);
       List<Residue> residues = segment.getListResidue().getResidue();
       for (Residue residue : residues)
       {
@@ -519,6 +520,7 @@ public class SiftsClient implements SiftsClientI
             {
               currSeqIndex = Integer.valueOf(resNumIndexString
                       .split("[a-zA-Z]")[0]);
+              continue;
             }
             if (pdbRefDb != null)
             {
@@ -647,18 +649,25 @@ public class SiftsClient implements SiftsClientI
   void populateAtomPositions(String chainId,
           HashMap<Integer, int[]> mapping) throws IllegalArgumentException
   {
-    PDBChain chain = pdb.findChain(chainId);
-    if (chain == null || mapping == null)
-    {
-      throw new IllegalArgumentException(
-              "Chain id or mapping must not be null.");
-    }
-    for (int[] map : mapping.values())
+    try
     {
-      if (map[PDB_RES_POS] != UNASSIGNED)
+      PDBChain chain = pdb.findChain(chainId);
+
+      if (chain == null || mapping == null)
       {
-        map[PDB_ATOM_POS] = getAtomIndex(map[PDB_RES_POS], chain.atoms);
+        throw new IllegalArgumentException(
+                "Chain id or mapping must not be null.");
       }
+      for (int[] map : mapping.values())
+      {
+        if (map[PDB_RES_POS] != UNASSIGNED)
+        {
+          map[PDB_ATOM_POS] = getAtomIndex(map[PDB_RES_POS], chain.atoms);
+        }
+      }
+    } catch (Exception e)
+    {
+      e.printStackTrace();
     }
   }
 
@@ -763,8 +772,8 @@ public class SiftsClient implements SiftsClientI
     Arrays.sort(keys);
     int firstIndex = keys[0];
     int lastIndex = keys[keys.length - 1];
-    System.out.println("Min value " + firstIndex);
-    System.out.println("Max value " + lastIndex);
+    // System.out.println("Min value " + firstIndex);
+    // System.out.println("Max value " + lastIndex);
     for (int x = firstIndex; x <= lastIndex; x++)
     {
       if (!resNumMap.containsKey(x) && !omitNonObserved.contains(x))
@@ -853,8 +862,8 @@ public class SiftsClient implements SiftsClientI
       ++count;
     }
     Arrays.sort(sPojo, Collections.reverseOrder());
-    System.out.println("highest matched entity : " + sPojo[0].entityId);
-    System.out.println("highest matched pid : " + sPojo[0].pid);
+    // System.out.println("highest matched entity : " + sPojo[0].entityId);
+    // System.out.println("highest matched pid : " + sPojo[0].pid);
 
     if (sPojo[0].entityId != null)
     {