X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FJalview2XML.java;h=88bb5f2f077d286219e8760ef45058e9e95f9517;hb=a6243461e1c57048d9b1f33a1df1f1a3980d5cb0;hp=85b7f86328547afe4f46a48093d006718089a3c6;hpb=49685e6426d5ac136dce4907196751680c667670;p=jalview.git diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 85b7f86..88bb5f2 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -36,13 +36,12 @@ import jalview.schemes.*; import jalview.structure.StructureSelectionManager; /** - * Write out the current jalview desktop state - * as a Jalview XML stream. + * Write out the current jalview desktop state as a Jalview XML stream. + * + * Note: the vamsas objects referred to here are primitive versions of the + * VAMSAS project schema elements - they are not the same and most likely never + * will be :) * - * Note: the vamsas objects referred to here are primitive - * versions of the VAMSAS project schema elements - they are - * not the same and most likely never will be :) - * * @author $author$ * @version $Revision$ */ @@ -50,49 +49,59 @@ public class Jalview2XML { /** * create/return unique hash string for sq + * * @param sq * @return new or existing unique string for sq */ String seqHash(SequenceI sq) { - if (seqsToIds==null) + if (seqsToIds == null) { initSeqRefs(); } if (seqsToIds.containsKey(sq)) { return (String) seqsToIds.get(sq); - } else { - // create sequential key - String key = "sq"+(seqsToIds.size()+1); + } + else + { + // create sequential key + String key = "sq" + (seqsToIds.size() + 1); seqsToIds.put(sq, key); return key; } } + void clearSeqRefs() { seqRefIds.clear(); seqsToIds.clear(); } + void initSeqRefs() { - if (seqsToIds==null) + if (seqsToIds == null) { seqsToIds = new IdentityHashMap(); } - if (seqRefIds==null) + if (seqRefIds == null) { seqRefIds = new Hashtable(); } } + java.util.IdentityHashMap seqsToIds = null; // SequenceI->key resolution + java.util.Hashtable seqRefIds = null; // key->SequenceI resolution Vector frefedSequence = null; + boolean raiseGUI = true; // whether errors are raised in dialog boxes or not + public Jalview2XML() { } + public Jalview2XML(boolean raiseGUI) { this.raiseGUI = raiseGUI; @@ -155,7 +164,11 @@ public class Jalview2XML } else { - System.err.println("IMPLEMENTATION WARNING: Unresolved forward reference for hash string "+ref[0]+" with objecttype "+ref[1].getClass()); + System.err + .println("IMPLEMENTATION WARNING: Unresolved forward reference for hash string " + + ref[0] + + " with objecttype " + + ref[1].getClass()); r++; } } @@ -169,9 +182,8 @@ public class Jalview2XML } /** - * This maintains a list of viewports, the key being the - * seqSetId. Important to set historyItem and redoList - * for multiple views + * This maintains a list of viewports, the key being the seqSetId. Important + * to set historyItem and redoList for multiple views */ Hashtable viewportsAdded; @@ -199,14 +211,14 @@ public class Jalview2XML FileOutputStream fos = new FileOutputStream(statefile); JarOutputStream jout = new JarOutputStream(fos); - //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS - //////////////////////////////////////////////////// - //NOTE ALSO new PrintWriter must be used for each new JarEntry + // NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS + // ////////////////////////////////////////////////// + // NOTE ALSO new PrintWriter must be used for each new JarEntry PrintWriter out = null; Vector shortNames = new Vector(); - //REVERSE ORDER + // REVERSE ORDER for (int i = frames.length - 1; i > -1; i--) { if (frames[i] instanceof AlignFrame) @@ -257,11 +269,18 @@ public class Jalview2XML } } } - try { jout.flush(); } catch (Exception foo) {}; + try + { + jout.flush(); + } catch (Exception foo) + { + } + ; jout.close(); } catch (Exception ex) { - //TODO: inform user of the problem - they need to know if their data was not saved ! + // TODO: inform user of the problem - they need to know if their data was + // not saved ! ex.printStackTrace(); } } @@ -287,7 +306,13 @@ public class Jalview2XML SaveState(apanel, jfileName, jout); } - try { jout.flush(); } catch (Exception foo) {}; + try + { + jout.flush(); + } catch (Exception foo) + { + } + ; jout.close(); return true; } catch (Exception ex) @@ -298,19 +323,23 @@ public class Jalview2XML } /** - * create a JalviewModel from an algnment view and marshall it - * to a JarOutputStream - * - * @param ap panel to create jalview model for - * @param fileName name of alignment panel written to output stream - * @param jout jar output stream - * @param out jar entry name + * create a JalviewModel from an algnment view and marshall it to a + * JarOutputStream + * + * @param ap + * panel to create jalview model for + * @param fileName + * name of alignment panel written to output stream + * @param jout + * jar output stream + * @param out + * jar entry name */ public JalviewModel SaveState(AlignmentPanel ap, String fileName, JarOutputStream jout) { initSeqRefs(); - + Vector userColours = new Vector(); AlignViewport av = ap.av; @@ -354,7 +383,7 @@ public class Jalview2XML JSeq jseq; - //SAVE SEQUENCES + // SAVE SEQUENCES String id = ""; jalview.datamodel.SequenceI jds; for (int i = 0; i < jal.getHeight(); i++) @@ -364,14 +393,19 @@ public class Jalview2XML if (seqRefIds.get(id) != null) { - // This happens for two reasons: 1. multiple views are being serialised. 2. the hashCode has collided with another sequence's code. This DOES HAPPEN! (PF00072.15.stk does this) - // JBPNote: Uncomment to debug writing out of files that do not read back in due to ArrayOutOfBoundExceptions. - //System.err.println("vamsasSeq backref: "+id+""); - //System.err.println(jds.getName()+" "+jds.getStart()+"-"+jds.getEnd()+" "+jds.getSequenceAsString()); - //System.err.println("Hashcode: "+seqHash(jds)); - //SequenceI rsq = (SequenceI) seqRefIds.get(id + ""); - //System.err.println(rsq.getName()+" "+rsq.getStart()+"-"+rsq.getEnd()+" "+rsq.getSequenceAsString()); - //System.err.println("Hashcode: "+seqHash(rsq)); + // This happens for two reasons: 1. multiple views are being serialised. + // 2. the hashCode has collided with another sequence's code. This DOES + // HAPPEN! (PF00072.15.stk does this) + // JBPNote: Uncomment to debug writing out of files that do not read + // back in due to ArrayOutOfBoundExceptions. + // System.err.println("vamsasSeq backref: "+id+""); + // System.err.println(jds.getName()+" + // "+jds.getStart()+"-"+jds.getEnd()+" "+jds.getSequenceAsString()); + // System.err.println("Hashcode: "+seqHash(jds)); + // SequenceI rsq = (SequenceI) seqRefIds.get(id + ""); + // System.err.println(rsq.getName()+" + // "+rsq.getStart()+"-"+rsq.getEnd()+" "+rsq.getSequenceAsString()); + // System.err.println("Hashcode: "+seqHash(rsq)); } else { @@ -464,7 +498,7 @@ public class Jalview2XML pdb.setType(entry.getType()); AppJmol jmol; - //This must have been loaded, is it still visible? + // This must have been loaded, is it still visible? JInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int f = frames.length - 1; f > -1; f--) { @@ -582,7 +616,7 @@ public class Jalview2XML for (int m = 0; m < pmaps.length; m++) { AlcodMap alcmap = new AlcodMap(); - alcmap.setDnasq("" + dnas[m].hashCode()); + alcmap.setDnasq("" + seqHash(dnas[m])); alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null, false)); alc.addAlcodMap(alcmap); @@ -591,8 +625,8 @@ public class Jalview2XML } } - //SAVE TREES - /////////////////////////////////// + // SAVE TREES + // ///////////////////////////////// if (av.currentTree != null) { // FIND ANY ASSOCIATED TREES @@ -636,7 +670,7 @@ public class Jalview2XML } } - //SAVE ANNOTATIONS + // SAVE ANNOTATIONS if (jal.getAlignmentAnnotation() != null) { jalview.datamodel.AlignmentAnnotation[] aa = jal @@ -739,7 +773,7 @@ public class Jalview2XML } } - //SAVE GROUPS + // SAVE GROUPS if (jal.getGroups() != null) { JGroup[] groups = new JGroup[jal.getGroups().size()]; @@ -809,7 +843,7 @@ public class Jalview2XML jms.setJGroup(groups); } - ///////////SAVE VIEWPORT + // /////////SAVE VIEWPORT Viewport view = new Viewport(); view.setTitle(ap.alignFrame.getTitle()); view.setSequenceSetId(av.getSequenceSetId()); @@ -933,7 +967,7 @@ public class Jalview2XML settingsAdded.addElement(renderOrder[ro]); } - //Make sure we save none displayed feature settings + // Make sure we save none displayed feature settings Enumeration en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours .keys(); while (en.hasMoreElements()) @@ -999,18 +1033,19 @@ public class Jalview2XML object.setJalviewModelSequence(jms); object.getVamsasModel().addSequenceSet(vamsasSet); - if (jout!=null && fileName!=null) + if (jout != null && fileName != null) { - //We may not want to write the object to disk, - //eg we can copy the alignViewport to a new view object - //using save and then load + // We may not want to write the object to disk, + // eg we can copy the alignViewport to a new view object + // using save and then load try { JarEntry entry = new JarEntry(fileName); jout.putNextEntry(entry); PrintWriter pout = new PrintWriter(new OutputStreamWriter(jout, - "UTF-8")); - org.exolab.castor.xml.Marshaller marshaller = new org.exolab.castor.xml.Marshaller(pout); + "UTF-8")); + org.exolab.castor.xml.Marshaller marshaller = new org.exolab.castor.xml.Marshaller( + pout); marshaller.marshal(object); pout.flush(); jout.closeEntry(); @@ -1047,7 +1082,8 @@ public class Jalview2XML } else { - vamsasSeq.setDsseqid(id); // so we can tell which sequences really are dataset sequences only + vamsasSeq.setDsseqid(id); // so we can tell which sequences really are + // dataset sequences only dbrefs = jds.getDBRef(); } if (dbrefs != null) @@ -1104,8 +1140,8 @@ public class Jalview2XML && (parentseq != jmp.getTo() || parentseq .getDatasetSequence() != jmp.getTo())) { - mpc.setSequence(createVamsasSequence(false, seqHash(jmp.getTo()) - , jmp.getTo(), jds)); + mpc.setSequence(createVamsasSequence(false, seqHash(jmp.getTo()), + jmp.getTo(), jds)); } else { @@ -1223,8 +1259,9 @@ public class Jalview2XML /** * DOCUMENT ME! - * - * @param file DOCUMENT ME! + * + * @param file + * DOCUMENT ME! */ public AlignFrame LoadJalviewAlign(final String file) { @@ -1241,7 +1278,7 @@ public class Jalview2XML try { - //UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING + // UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING URL url = null; if (file.startsWith("http://")) @@ -1287,7 +1324,7 @@ public class Jalview2XML } else if (jarentry != null) { - //Some other file here. + // Some other file here. entryCount++; } } while (jarentry != null); @@ -1308,11 +1345,13 @@ public class Jalview2XML { System.err.println("Parsing as Jalview Version 2 file failed."); ex.printStackTrace(System.err); - - //Is Version 1 Jar file? - try { + + // Is Version 1 Jar file? + try + { af = new Jalview2XML_V1(raiseGUI).LoadJalviewAlign(file); - } catch (Exception ex2) { + } catch (Exception ex2) + { System.err.println("Exception whilst loading as jalviewXMLV1:"); ex2.printStackTrace(); af = null; @@ -1348,19 +1387,21 @@ public class Jalview2XML { final String finalErrorMessage = errorMessage; if (raiseGUI) - { + { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() - { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - finalErrorMessage, "Error loading Jalview file", - JOptionPane.WARNING_MESSAGE); - } - }); - } else { - System.err.println("Problem loading Jalview file: "+errorMessage); - } + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + finalErrorMessage, "Error loading Jalview file", + JOptionPane.WARNING_MESSAGE); + } + }); + } + else + { + System.err.println("Problem loading Jalview file: " + errorMessage); + } } return af; @@ -1405,7 +1446,13 @@ public class Jalview2XML { out.println(data); } - try { out.flush(); } catch (Exception foo) {}; + try + { + out.flush(); + } catch (Exception foo) + { + } + ; out.close(); alreadyLoadedPDB.put(pdbId, outFile.getAbsolutePath()); @@ -1429,8 +1476,8 @@ public class Jalview2XML Viewport view = jms.getViewport(0); - ////////////////////////////////// - //LOAD SEQUENCES + // //////////////////////////////// + // LOAD SEQUENCES Vector hiddenSeqs = null; jalview.datamodel.Sequence jseq; @@ -1440,7 +1487,7 @@ public class Jalview2XML boolean multipleView = false; JSeq[] JSEQ = object.getJalviewModelSequence().getJSeq(); - int vi=0; // counter in vamsasSeq array + int vi = 0; // counter in vamsasSeq array for (int i = 0; i < JSEQ.length; i++) { String seqId = JSEQ[i].getId() + ""; @@ -1458,7 +1505,7 @@ public class Jalview2XML jseq.setStart(JSEQ[i].getStart()); jseq.setEnd(JSEQ[i].getEnd()); jseq.setVamsasId(uniqueSetSuffix + seqId); - seqRefIds.put(vamsasSeq[vi].getId()+"", jseq); + seqRefIds.put(vamsasSeq[vi].getId() + "", jseq); tmpseqs.add(jseq); vi++; } @@ -1476,9 +1523,9 @@ public class Jalview2XML } - /// + // / // Create the alignment object from the sequence set - ///////////////////////////////// + // /////////////////////////////// jalview.datamodel.Sequence[] orderedSeqs = new jalview.datamodel.Sequence[tmpseqs .size()]; @@ -1487,17 +1534,17 @@ public class Jalview2XML jalview.datamodel.Alignment al = new jalview.datamodel.Alignment( orderedSeqs); - /// Add the alignment properties + // / Add the alignment properties for (int i = 0; i < vamsasSet.getSequenceSetPropertiesCount(); i++) { SequenceSetProperties ssp = vamsasSet.getSequenceSetProperties(i); al.setProperty(ssp.getKey(), ssp.getValue()); } - /// + // / // SequenceFeatures are added to the DatasetSequence, // so we must create or recover the dataset before loading features - ///////////////////////////////// + // /////////////////////////////// if (vamsasSet.getDatasetId() == null || vamsasSet.getDatasetId() == "") { // older jalview projects do not have a dataset id. @@ -1507,7 +1554,7 @@ public class Jalview2XML { recoverDatasetFor(vamsasSet, al); } - ///////////////////////////////// + // /////////////////////////////// Hashtable pdbloaded = new Hashtable(); if (!multipleView) @@ -1572,7 +1619,7 @@ public class Jalview2XML } } - ///////////////////////////////// + // /////////////////////////////// // LOAD SEQUENCE MAPPINGS if (vamsasSet.getAlcodonFrameCount() > 0) { @@ -1604,15 +1651,17 @@ public class Jalview2XML // attach to dna sequence reference. if (maps[m].getMapping() != null) { - mapping = addMapping(maps[m] - .getMapping()); + mapping = addMapping(maps[m].getMapping()); } if (dnaseq != null) { - cf.addMap(dnaseq, mapping.getTo(), mapping.getMap()); - } else { + cf.addMap(dnaseq, mapping.getTo(), mapping.getMap()); + } + else + { // defer to later - frefedSequence.add(new Object[] { maps[m].getDnasq(), cf, mapping}); + frefedSequence.add(new Object[] + { maps[m].getDnasq(), cf, mapping }); } } } @@ -1621,8 +1670,8 @@ public class Jalview2XML } - ////////////////////////////////// - //LOAD ANNOTATIONS + // //////////////////////////////// + // LOAD ANNOTATIONS boolean hideQuality = true, hideConservation = true, hideConsensus = true; if (vamsasSet.getAnnotationCount() > 0) @@ -1678,14 +1727,15 @@ public class Jalview2XML .getSecondaryStructure() == null || ae[aa] .getSecondaryStructure().length() == 0) ? ' ' : ae[aa] .getSecondaryStructure().charAt(0), ae[aa].getValue() - + ); - // JBPNote: Consider verifying dataflow for IO of secondary structure annotation read from Stockholm files - // this was added to try to ensure that - //if (anot[ae[aa].getPosition()].secondaryStructure>' ') - //{ - // anot[ae[aa].getPosition()].displayCharacter = ""; - //} + // JBPNote: Consider verifying dataflow for IO of secondary + // structure annotation read from Stockholm files + // this was added to try to ensure that + // if (anot[ae[aa].getPosition()].secondaryStructure>' ') + // { + // anot[ae[aa].getPosition()].displayCharacter = ""; + // } anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa] .getColour()); } @@ -1742,8 +1792,8 @@ public class Jalview2XML } } - ///////////////////////// - //LOAD GROUPS + // /////////////////////// + // LOAD GROUPS if (jms.getJGroupCount() > 0) { JGroup[] groups = jms.getJGroup(); @@ -1815,7 +1865,7 @@ public class Jalview2XML } } - ///////////////////////////////// + // /////////////////////////////// // LOAD VIEWPORT AlignFrame af = new AlignFrame(al, view.getWidth(), view.getHeight()); @@ -1828,10 +1878,10 @@ public class Jalview2XML new java.awt.Color(JSEQ[i].getColour())); } - //If we just load in the same jar file again, the sequenceSetId - //will be the same, and we end up with multiple references - //to the same sequenceSet. We must modify this id on load - //so that each load of the file gives a unique id + // If we just load in the same jar file again, the sequenceSetId + // will be the same, and we end up with multiple references + // to the same sequenceSet. We must modify this id on load + // so that each load of the file gives a unique id String uniqueSeqSetId = view.getSequenceSetId() + uniqueSetSuffix; af.viewport.gatherViewsHere = view.getGatheredViews(); @@ -1948,7 +1998,7 @@ public class Jalview2XML } else if (view.getBgColour().startsWith("Annotation")) { - //int find annotation + // int find annotation for (int i = 0; i < af.viewport.alignment.getAlignmentAnnotation().length; i++) { if (af.viewport.alignment.getAlignmentAnnotation()[i].label @@ -2005,17 +2055,16 @@ public class Jalview2XML continue; } - /* if (view.getAnnotationColours().getColourScheme().equals("None")) - { - sg.cs = new AnnotationColourGradient( - af.viewport.alignment.getAlignmentAnnotation()[i], - new java.awt.Color(view.getAnnotationColours(). - getMinColour()), - new java.awt.Color(view.getAnnotationColours(). - getMaxColour()), - view.getAnnotationColours().getAboveThreshold()); - } - else*/ + /* + * if + * (view.getAnnotationColours().getColourScheme().equals("None")) { + * sg.cs = new AnnotationColourGradient( + * af.viewport.alignment.getAlignmentAnnotation()[i], new + * java.awt.Color(view.getAnnotationColours(). getMinColour()), + * new java.awt.Color(view.getAnnotationColours(). + * getMaxColour()), + * view.getAnnotationColours().getAboveThreshold()); } else + */ { sg.cs = new AnnotationColourGradient( af.viewport.alignment.getAlignmentAnnotation()[i], @@ -2100,7 +2149,7 @@ public class Jalview2XML for (int c = 0; c < view.getHiddenColumnsCount(); c++) { af.viewport.hideColumns(view.getHiddenColumns(c).getStart(), view - .getHiddenColumns(c).getEnd() //+1 + .getHiddenColumns(c).getEnd() // +1 ); } } @@ -2110,8 +2159,8 @@ public class Jalview2XML Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(), view .getHeight()); - //LOAD TREES - /////////////////////////////////////// + // LOAD TREES + // ///////////////////////////////////// if (loadTreesAndStructures && jms.getTreeCount() > 0) { try @@ -2157,7 +2206,7 @@ public class Jalview2XML } } - ////LOAD STRUCTURES + // //LOAD STRUCTURES if (loadTreesAndStructures) { for (int i = 0; i < JSEQ.length; i++) @@ -2180,21 +2229,26 @@ public class Jalview2XML int height = ids[p].getStructureState(s).getHeight(); java.awt.Component comp = null; - + JInternalFrame[] frames = null; - do { - try { + do + { + try + { frames = Desktop.desktop.getAllFrames(); - } - catch (ArrayIndexOutOfBoundsException e) + } catch (ArrayIndexOutOfBoundsException e) { // occasional No such child exceptions are thrown here... frames = null; - try { + try + { Thread.sleep(10); - } catch (Exception f) {}; + } catch (Exception f) + { + } + ; } - } while (frames==null); + } while (frames == null); for (int f = 0; f < frames.length; f++) { if (frames[f] instanceof AppJmol) @@ -2278,26 +2332,31 @@ public class Jalview2XML al.setDataset(ds); } } - /** * - * @param vamsasSeq sequence definition to create/merge dataset sequence for - * @param ds dataset alignment - * @param dseqs vector to add new dataset sequence to + * @param vamsasSeq + * sequence definition to create/merge dataset sequence for + * @param ds + * dataset alignment + * @param dseqs + * vector to add new dataset sequence to */ - private void ensureJalviewDatasetSequence(Sequence vamsasSeq, AlignmentI ds, Vector dseqs) + private void ensureJalviewDatasetSequence(Sequence vamsasSeq, + AlignmentI ds, Vector dseqs) { - // JBP TODO: Check this is called for AlCodonFrames to support recovery of xRef Codon Maps - jalview.datamodel.Sequence sq = (jalview.datamodel.Sequence) seqRefIds.get(vamsasSeq.getId()); + // JBP TODO: Check this is called for AlCodonFrames to support recovery of + // xRef Codon Maps + jalview.datamodel.Sequence sq = (jalview.datamodel.Sequence) seqRefIds + .get(vamsasSeq.getId()); jalview.datamodel.SequenceI dsq = null; - if (sq!=null && sq.getDatasetSequence()!=null) + if (sq != null && sq.getDatasetSequence() != null) { dsq = (jalview.datamodel.SequenceI) sq.getDatasetSequence(); } - + String sqid = vamsasSeq.getDsseqid(); - if (dsq==null) + if (dsq == null) { // need to create or add a new dataset sequence reference to this sequence if (sqid != null) @@ -2318,7 +2377,7 @@ public class Jalview2XML seqRefIds.put(sqid, dsq); if (ds == null) { - if (dseqs!=null) + if (dseqs != null) { dseqs.addElement(dsq); } @@ -2327,48 +2386,45 @@ public class Jalview2XML { ds.addSequence(dsq); } - } else { - if (sq!=dsq) - { // make this dataset sequence sq's dataset sequence + } + else + { + if (sq != dsq) + { // make this dataset sequence sq's dataset sequence sq.setDatasetSequence(dsq); } } } // TODO: refactor this as a merge dataset sequence function - // now check that sq (the dataset sequence) sequence really is the union of all references to it - //boolean pre = sq.getStart() < dsq.getStart(); - //boolean post = sq.getEnd() > dsq.getEnd(); - //if (pre || post) - if (sq!=dsq) + // now check that sq (the dataset sequence) sequence really is the union of + // all references to it + // boolean pre = sq.getStart() < dsq.getStart(); + // boolean post = sq.getEnd() > dsq.getEnd(); + // if (pre || post) + if (sq != dsq) { StringBuffer sb = new StringBuffer(); String newres = jalview.analysis.AlignSeq.extractGaps( jalview.util.Comparison.GapChars, sq.getSequenceAsString()); - if (!newres.equalsIgnoreCase(dsq.getSequenceAsString()) && newres.length()>dsq.getLength()) + if (!newres.equalsIgnoreCase(dsq.getSequenceAsString()) + && newres.length() > dsq.getLength()) { // Update with the longer sequence. synchronized (dsq) { - /*if (pre) - { - sb.insert(0, newres - .substring(0, dsq.getStart() - sq.getStart())); - dsq.setStart(sq.getStart()); - } - if (post) - { - sb.append(newres.substring(newres.length() - sq.getEnd() - - dsq.getEnd())); - dsq.setEnd(sq.getEnd()); - } - */ - dsq.setSequence(sb.toString()); + /* + * if (pre) { sb.insert(0, newres .substring(0, dsq.getStart() - + * sq.getStart())); dsq.setStart(sq.getStart()); } if (post) { + * sb.append(newres.substring(newres.length() - sq.getEnd() - + * dsq.getEnd())); dsq.setEnd(sq.getEnd()); } + */ + dsq.setSequence(sb.toString()); } - //TODO: merges will never happen if we 'know' we have the real dataset sequence - this should be detected when id==dssid - System.err - .println("DEBUG Notice: Merged dataset sequence"); // (" - // + (pre ? "prepended" : "") + " " - //+ (post ? "appended" : "")); + // TODO: merges will never happen if we 'know' we have the real dataset + // sequence - this should be detected when id==dssid + System.err.println("DEBUG Notice: Merged dataset sequence"); // (" + // + (pre ? "prepended" : "") + " " + // + (post ? "appended" : "")); } } } @@ -2460,35 +2516,41 @@ public class Jalview2XML * local sequence definition */ Sequence ms = mc.getSequence(); - jalview.datamodel.Sequence djs=null; + jalview.datamodel.Sequence djs = null; String sqid = ms.getDsseqid(); - if (sqid!=null && sqid.length()>0) + if (sqid != null && sqid.length() > 0) { /* * recover dataset sequence */ djs = (jalview.datamodel.Sequence) seqRefIds.get(sqid); - } else { - System.err.println("Warning - making up dataset sequence id for DbRef sequence map reference"); - sqid = ((Object)ms).toString(); // make up a new hascode for undefined dataset sequence hash (unlikely to happen) } - - if (djs==null) { + else + { + System.err + .println("Warning - making up dataset sequence id for DbRef sequence map reference"); + sqid = ((Object) ms).toString(); // make up a new hascode for + // undefined dataset sequence hash + // (unlikely to happen) + } + + if (djs == null) + { /** * make a new dataset sequence and add it to refIds hash */ - djs = new jalview.datamodel.Sequence(ms - .getName(), ms.getSequence()); + djs = new jalview.datamodel.Sequence(ms.getName(), ms + .getSequence()); djs.setStart(jmap.getMap().getToLowest()); djs.setEnd(jmap.getMap().getToHighest()); djs.setVamsasId(uniqueSetSuffix + sqid); jmap.setTo(djs); seqRefIds.put(sqid, djs); - + } jalview.bin.Cache.log.debug("about to recurse on addDBRefs."); addDBRefs(djs, ms); - + } } return (jmap); @@ -2498,8 +2560,8 @@ public class Jalview2XML public jalview.gui.AlignmentPanel copyAlignPanel(AlignmentPanel ap, boolean keepSeqRefs) { - jalview.schemabinding.version2.JalviewModel jm = - SaveState(ap, null, null); + jalview.schemabinding.version2.JalviewModel jm = SaveState(ap, null, + null); if (!keepSeqRefs) { @@ -2517,21 +2579,19 @@ public class Jalview2XML af.alignPanels.clear(); af.closeMenuItem_actionPerformed(true); - /* if(ap.av.alignment.getAlignmentAnnotation()!=null) - { - for(int i=0; i