From 1cb953ba4613be2af16e73eb131abf0f3d8d4234 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 30 Oct 2014 16:53:20 +0000 Subject: [PATCH] JAL-674 hang on to sequences created by secondary parsiing process to manage transfer of annotation --- src/MCview/PDBChain.java | 56 ++++++++++++++++++++++++++++++++++++++++++++-- src/MCview/PDBfile.java | 44 ++++++++++++++++++++++++++++++++---- 2 files changed, 94 insertions(+), 6 deletions(-) diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 6055a5b..5dd38a4 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -23,6 +23,7 @@ package MCview; import jalview.analysis.AlignSeq; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; +import jalview.datamodel.Mapping; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; @@ -53,7 +54,16 @@ public class PDBChain public int offset; - public Sequence sequence; + /** + * sequence is the sequence extracted by the chain parsing code + */ + public SequenceI sequence; + + /** + * shadow is the sequence created by any other parsing processes (e.g. Jmol, + * RNAview) + */ + public SequenceI shadow = null; public boolean isNa = false; @@ -80,6 +90,8 @@ public class PDBChain */ protected String newline = System.getProperty("line.separator"); + public Mapping shadowMap; + public void setNewlineString(String nl) { newline = nl; @@ -493,11 +505,51 @@ public class PDBChain public void transferResidueAnnotation(StructureMapping mapping) { SequenceI sq = mapping.getSequence(); + SequenceI dsq = sq; if (sq != null) { - if (sequence != null && sequence.getAnnotation() != null) + while (dsq.getDatasetSequence() != null) + { + dsq = dsq.getDatasetSequence(); + } + // any annotation will be transferred onto the dataset sequence + + if (shadow != null && shadow.getAnnotation() != null) { + for (AlignmentAnnotation ana : shadow.getAnnotation()) + { + List transfer = sq.getAlignmentAnnotations( + ana.getCalcId(), ana.label); + if (transfer == null || transfer.size() == 0) + { + ana.liftOver(sequence, shadowMap); + mapping.transfer(ana); + } + else + { + continue; + } + } + } + else + { + if (sequence != null && sequence.getAnnotation() != null) + { + for (AlignmentAnnotation ana : sequence.getAnnotation()) + { + List transfer = sq.getAlignmentAnnotations( + ana.getCalcId(), ana.label); + if (transfer == null || transfer.size() == 0) + { + mapping.transfer(ana); + } + else + { + continue; + } + } + } } float min = -1, max = 0; Annotation[] an = new Annotation[sq.getEnd() - sq.getStart() + 1]; diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index 7d2ceac..11e7188 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -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 prot, + AlignmentI al, String pep, boolean b) + { + List> replaced = AlignSeq + .replaceMatchingSeqsWith(seqs, + annotations, prot, al, AlignSeq.PEP, false); + for (PDBChain ch : chains) + { + int p = 0; + for (SequenceI sq : (List) 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 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) { -- 1.7.10.2