JAL-674 hang on to sequences created by secondary parsiing process to manage transfer...
[jalview.git] / src / MCview / PDBfile.java
index 7d2ceac..11e7188 100755 (executable)
@@ -339,13 +339,43 @@ public class PDBfile extends jalview.io.AlignFile
             sq.getPDBId().clear();
           }
         }
-        AlignSeq.replaceMatchingSeqsWith(seqs, annotations, prot, al, AlignSeq.PEP, false);
+        replaceAndUpdateChains(prot, al, AlignSeq.PEP, false);
       }
     } catch (ClassNotFoundException q)
     {
     }
   }
 
+  private void replaceAndUpdateChains(ArrayList<SequenceI> prot,
+          AlignmentI al, String pep, boolean b)
+  {
+    List<List<? extends Object>> replaced = AlignSeq
+            .replaceMatchingSeqsWith(seqs,
+            annotations, prot, al, AlignSeq.PEP, false);
+    for (PDBChain ch : chains)
+    {
+      int p = 0;
+      for (SequenceI sq : (List<SequenceI>) replaced.get(0))
+      {
+        p++;
+        if (sq == ch.sequence || sq.getDatasetSequence() == ch.sequence)
+        {
+          p = -p;
+          break;
+        }
+      }
+      if (p < 0)
+      {
+        p = -p - 1;
+        // set shadow entry for chains
+        ch.shadow = (SequenceI) replaced.get(1).get(p);
+        ch.shadowMap = ((AlignSeq) replaced.get(2)
+.get(p))
+                .getMappingFromS1(false);
+      }
+    }
+  }
+
   private void processPdbFileWithAnnotate3d(ArrayList<SequenceI> rna)
           throws Exception
   {
@@ -371,14 +401,20 @@ public class PDBfile extends jalview.io.AlignFile
         {
           if (sq.getDatasetSequence() != null)
           {
-            sq.getDatasetSequence().getPDBId().clear();
+            if (sq.getDatasetSequence().getPDBId() != null)
+            {
+              sq.getDatasetSequence().getPDBId().clear();
+            }
           }
           else
           {
-            sq.getPDBId().clear();
+            if (sq.getPDBId() != null)
+            {
+              sq.getPDBId().clear();
+            }
           }
         }
-        AlignSeq.replaceMatchingSeqsWith(seqs, annotations, rna, al, AlignSeq.DNA, false);
+        replaceAndUpdateChains(rna, al, AlignSeq.DNA, false);
       }
     } catch (ClassNotFoundException x)
     {