*/\r
package jalview.gui;\r
\r
-import jalview.binding.*;\r
-\r
-import jalview.io.*;\r
\r
import jalview.schemes.*;\r
\r
+import jalview.gui.*;\r
+\r
import java.io.*;\r
\r
import java.net.*;\r
\r
import java.util.*;\r
+\r
import java.util.jar.*;\r
\r
import javax.swing.*;\r
\r
+import org.exolab.castor.xml.*;\r
+\r
+import jalview.schemabinding.version2.*;\r
+\r
+\r
+\r
\r
/**\r
* DOCUMENT ME!\r
public class Jalview2XML\r
{\r
// SAVES SEVERAL ALIGNEMENT WINDOWS TO SAME JARFILE\r
- public static void SaveState(File statefile)\r
+ public void SaveState(File statefile)\r
{\r
long creation = System.currentTimeMillis();\r
JInternalFrame[] frames = Desktop.desktop.getAllFrames();\r
}\r
\r
// USE THIS METHOD TO SAVE A SINGLE ALIGNMENT WINDOW\r
- public static void SaveAlignment(AlignFrame af, String jarFile,\r
+ public void SaveAlignment(AlignFrame af, String jarFile,\r
String fileName)\r
{\r
try\r
* @param jout DOCUMENT ME!\r
* @param out DOCUMENT ME!\r
*/\r
- public static void SaveState(AlignFrame af, long timeStamp,\r
+ public void SaveState(AlignFrame af, long timeStamp,\r
String fileName, JarOutputStream jout, PrintWriter out)\r
{\r
Vector seqids = new Vector();\r
AlignViewport av = af.viewport;\r
\r
JalviewModel object = new JalviewModel();\r
- object.setVamsasModel(new VamsasModel());\r
+ object.setVamsasModel(new jalview.schemabinding.version2.VamsasModel());\r
\r
object.setCreationDate(new java.util.Date(timeStamp));\r
object.setVersion(jalview.bin.Cache.getProperty("VERSION"));\r
\r
jalview.datamodel.AlignmentI jal = af.viewport.alignment;\r
+ jalview.datamodel.AlignmentI jalhidden = null;\r
+\r
+ if(av.hasHiddenRows)\r
+ {\r
+ jalhidden = jal;\r
+ jal = jal.getHiddenSequences().getFullAlignment();\r
+ }\r
+\r
\r
SequenceSet vamsasSet = new SequenceSet();\r
Sequence vamsasSeq;\r
vamsasSet.setGapChar(jal.getGapCharacter() + "");\r
\r
JSeq jseq;\r
+ Vector pdbfiles = null;\r
\r
//SAVE SEQUENCES\r
int id = 0;\r
-\r
for (int i = 0; i < jal.getHeight(); i++)\r
{\r
seqids.add(jal.getSequenceAt(i));\r
-\r
vamsasSeq = new Sequence();\r
vamsasSeq.setId(id + "");\r
vamsasSeq.setName(jal.getSequenceAt(i).getName());\r
vamsasSeq.setSequence(jal.getSequenceAt(i).getSequence());\r
+ vamsasSeq.setDescription(jal.getSequenceAt(i).getDescription());\r
+\r
+ if(jal.getSequenceAt(i).getDatasetSequence().getDBRef()!=null)\r
+ {\r
+ jalview.datamodel.DBRefEntry [] dbrefs =\r
+ jal.getSequenceAt(i).getDatasetSequence().getDBRef();\r
+\r
+ for(int d=0; d<dbrefs.length; d++)\r
+ {\r
+ DBRef dbref = new DBRef();\r
+ dbref.setSource( dbrefs[d].getSource() );\r
+ dbref.setVersion( dbrefs[d].getVersion());\r
+ dbref.setAccessionId(dbrefs[d].getAccessionId());\r
+ vamsasSeq.addDBRef(dbref);\r
+ }\r
+ }\r
\r
jseq = new JSeq();\r
jseq.setStart(jal.getSequenceAt(i).getStart());\r
jseq.setEnd(jal.getSequenceAt(i).getEnd());\r
-\r
jseq.setColour(jal.getSequenceAt(i).getColor().getRGB());\r
\r
jseq.setId(id);\r
\r
+ if (av.hasHiddenRows)\r
+ {\r
+ jseq.setHidden(jalhidden.getHiddenSequences().isHidden(\r
+ jal.getSequenceAt(i)));\r
+\r
+ if(jal.getSequenceAt(i).getHiddenSequences()!=null)\r
+ {\r
+ jalview.datamodel.SequenceI [] reps =\r
+ jal.getSequenceAt(i).getHiddenSequences().getSequencesInOrder(jal);\r
+\r
+ for(int h=0; h<reps.length; h++)\r
+ {\r
+ jseq.addHiddenSequences(\r
+ jal.findIndex(reps[h])\r
+ );\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ if(jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures()!=null)\r
+ {\r
+ jalview.datamodel.SequenceFeature[] sf\r
+ = jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures();\r
+ int index = 0;\r
+ while(index < sf.length)\r
+ {\r
+ Features features = new Features();\r
+\r
+ features.setBegin(sf[index].getBegin());\r
+ features.setEnd(sf[index].getEnd());\r
+ features.setDescription(sf[index].getDescription());\r
+ features.setType(sf[index].getType());\r
+ features.setFeatureGroup(sf[index].getFeatureGroup());\r
+ jseq.addFeatures(features);\r
+ index ++;\r
+ }\r
+ }\r
+\r
+ if(jal.getSequenceAt(i).getDatasetSequence().getPDBId()!=null)\r
+ {\r
+ Enumeration en = jal.getSequenceAt(i).getDatasetSequence().getPDBId().elements();\r
+ while(en.hasMoreElements())\r
+ {\r
+ Pdbids pdb = new Pdbids();\r
+ jalview.datamodel.PDBEntry entry\r
+ = (jalview.datamodel.PDBEntry)en.nextElement();\r
+\r
+ pdb.setId(entry.getId());\r
+ pdb.setType(entry.getType());\r
+\r
+ if(entry.getFile()!=null)\r
+ {\r
+ if(pdbfiles==null)\r
+ pdbfiles = new Vector();\r
+\r
+\r
+ if(!pdbfiles.contains(entry.getId()))\r
+ {\r
+ pdbfiles.addElement(entry.getId());\r
+ try\r
+ {\r
+ File file = new File(entry.getFile());\r
+ if(file.exists())\r
+ {\r
+ byte[] data = new byte[ (int) file.length()];\r
+ jout.putNextEntry(new JarEntry(entry.getId()));\r
+ DataInputStream dis = new DataInputStream(new\r
+ FileInputStream(file));\r
+ dis.readFully(data);\r
+\r
+ DataOutputStream dout = new DataOutputStream(jout);\r
+ dout.write(data, 0, data.length);\r
+ jout.closeEntry();\r
+ }\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ if(entry.getProperty()!=null)\r
+ {\r
+ PdbentryItem item = new PdbentryItem();\r
+ Hashtable properties = entry.getProperty();\r
+ Enumeration en2 = properties.keys();\r
+ while(en2.hasMoreElements())\r
+ {\r
+ Property prop = new Property();\r
+ String key = en2.nextElement().toString();\r
+ prop.setName(key);\r
+ prop.setValue( properties.get(key).toString() );\r
+ item.addProperty(prop);\r
+ }\r
+ pdb.addPdbentryItem(item);\r
+ }\r
+\r
+ jseq.addPdbids(pdb);\r
+ }\r
+ }\r
+\r
jms.addJSeq(jseq);\r
vamsasSet.addSequence(vamsasSeq);\r
id++;\r
tree.setThreshold(tp.treeCanvas.threshold);\r
\r
tree.setFitToWindow(tp.fitToWindow.getState());\r
- tree.setFontSize(tp.treeCanvas.fontSize);\r
+ tree.setFontName(tp.getTreeFont().getName());\r
+ tree.setFontSize(tp.getTreeFont().getSize());\r
+ tree.setFontStyle(tp.getTreeFont().getStyle());\r
tree.setMarkUnlinked(tp.placeholdersMenu.getState());\r
+\r
tree.setShowBootstrap(tp.bootstrapMenu.getState());\r
tree.setShowDistances(tp.distanceMenu.getState());\r
\r
\r
for (int i = 0; i < aa.length; i++)\r
{\r
+ Annotation an = new Annotation();\r
+\r
if (aa[i].label.equals("Quality") ||\r
aa[i].label.equals("Conservation") ||\r
aa[i].label.equals("Consensus"))\r
{\r
+ an.setLabel(aa[i].label);\r
+ an.setGraph(true);\r
+ vamsasSet.addAnnotation(an);\r
continue;\r
}\r
\r
- Annotation an = new Annotation();\r
+\r
an.setDescription(aa[i].description);\r
- an.setGraph(aa[i].isGraph);\r
+\r
+ if(aa[i].sequenceRef!=null)\r
+ {\r
+ an.setSequenceRef(aa[i].sequenceRef.getName());\r
+ }\r
+\r
+ if(aa[i].graph>0)\r
+ {\r
+ an.setGraph(true);\r
+ an.setGraphType(aa[i].graph);\r
+ an.setGraphGroup(aa[i].graphGroup);\r
+ if(aa[i].getThreshold()!=null)\r
+ {\r
+ ThresholdLine line = new ThresholdLine();\r
+ line.setLabel(aa[i].getThreshold().label);\r
+ line.setValue(aa[i].getThreshold().value);\r
+ line.setColour(aa[i].getThreshold().colour.getRGB());\r
+ an.setThresholdLine(line);\r
+ }\r
+ }\r
+ else\r
+ an.setGraph(false);\r
+\r
an.setLabel(aa[i].label);\r
\r
AnnotationElement ae;\r
ae.setPosition(a);\r
ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure +\r
"");\r
+\r
+ if(aa[i].annotations[a].colour!=java.awt.Color.black)\r
+ ae.setColour(aa[i].annotations[a].colour.getRGB());\r
+\r
an.addAnnotationElement(ae);\r
}\r
\r
groups[i].setStart(sg.getStartRes());\r
groups[i].setEnd(sg.getEndRes());\r
groups[i].setName(sg.getName());\r
-\r
- if (sg.cs instanceof ConservationColourScheme)\r
+ if(sg.cs!=null)\r
{\r
- groups[i].setConsThreshold(((ConservationColourScheme) sg.cs).inc);\r
- }\r
+ if (sg.cs.conservationApplied())\r
+ {\r
+ groups[i].setConsThreshold(sg.cs.getConservationInc());\r
\r
- if (sg.cs instanceof ResidueColourScheme)\r
- {\r
- groups[i].setPidThreshold(((ResidueColourScheme) sg.cs).getThreshold());\r
- }\r
- else if (sg.cs instanceof ScoreColourScheme)\r
- {\r
- groups[i].setPidThreshold(((ScoreColourScheme) sg.cs).getThreshold());\r
- }\r
-\r
- if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
- {\r
+ if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
+ {\r
+ groups[i].setColour(SetUserColourScheme(sg.cs,\r
+ userColours,\r
+ jms));\r
+ }\r
+ else\r
+ {\r
+ groups[i].setColour(ColourSchemeProperty.getColourName(sg.\r
+ cs));\r
+ }\r
+ }\r
+ else if(sg.cs instanceof jalview.schemes.AnnotationColourGradient)\r
+ {\r
+ groups[i].setColour(\r
+ ColourSchemeProperty.getColourName(\r
+ ( (jalview.schemes.AnnotationColourGradient) sg.cs).getBaseColour()));\r
+ }\r
+ else if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
+ {\r
groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
- jms));\r
- }\r
- else\r
- {\r
+ jms));\r
+ }\r
+ else\r
+ {\r
groups[i].setColour(ColourSchemeProperty.getColourName(\r
- sg.cs));\r
+ sg.cs));\r
+ }\r
+\r
+ groups[i].setPidThreshold(sg.cs.getThreshold());\r
}\r
\r
groups[i].setOutlineColour(sg.getOutlineColour().getRGB());\r
groups[i].setDisplayText(sg.getDisplayText());\r
groups[i].setColourText(sg.getColourText());\r
\r
- for (int s = 0; s < sg.getSize(); s++)\r
+ for (int s = 0; s < sg.getSize(false); s++)\r
{\r
jalview.datamodel.Sequence seq = (jalview.datamodel.Sequence) sg.getSequenceAt(s);\r
int index = seqids.indexOf(seq);\r
jms.setJGroup(groups);\r
}\r
\r
+\r
///////////SAVE VIEWPORT\r
Viewport view = new Viewport();\r
view.setTitle(af.getTitle());\r
view.setBgColour(SetUserColourScheme(av.getGlobalColourScheme(),\r
userColours, jms));\r
}\r
+ else if(av.getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)\r
+ {\r
+ jalview.schemes.AnnotationColourGradient acg\r
+ = (jalview.schemes.AnnotationColourGradient)av.getGlobalColourScheme();\r
+\r
+ AnnotationColours ac = new AnnotationColours();\r
+ ac.setAboveThreshold(acg.getAboveThreshold());\r
+ ac.setThreshold(acg.getAnnotationThreshold());\r
+ ac.setAnnotation(acg.getAnnotation());\r
+ if(acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)\r
+ ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),\r
+ userColours, jms));\r
+ else\r
+ ac.setColourScheme(ColourSchemeProperty.getColourName(acg.getBaseColour()));\r
+\r
+ ac.setMaxColour(acg.getMaxColour().getRGB());\r
+ ac.setMinColour(acg.getMinColour().getRGB());\r
+ view.setAnnotationColours(ac);\r
+ view.setBgColour("AnnotationColourGradient");\r
+ }\r
else\r
{\r
view.setBgColour(ColourSchemeProperty.getColourName(\r
\r
ColourSchemeI cs = av.getGlobalColourScheme();\r
\r
- if (cs instanceof ConservationColourScheme)\r
+ if(cs!=null)\r
{\r
- view.setConsThreshold(((ConservationColourScheme) cs).inc);\r
- }\r
+ if (cs.conservationApplied())\r
+ {\r
+ view.setConsThreshold(cs.getConservationInc());\r
+ if (cs instanceof jalview.schemes.UserColourScheme)\r
+ view.setBgColour(SetUserColourScheme(cs, userColours, jms));\r
+ }\r
\r
- if (cs instanceof ResidueColourScheme)\r
- {\r
- view.setPidThreshold(((ResidueColourScheme) cs).getThreshold());\r
- }\r
- else if (cs instanceof ScoreColourScheme)\r
- {\r
- view.setPidThreshold(((ScoreColourScheme) cs).getThreshold());\r
+ if (cs instanceof ResidueColourScheme)\r
+ {\r
+ view.setPidThreshold(cs.getThreshold());\r
+ }\r
}\r
\r
view.setConservationSelected(av.getConservationSelected());\r
view.setShowBoxes(av.getShowBoxes());\r
view.setShowColourText(av.getColourText());\r
view.setShowConservation(av.showConservation);\r
- view.setShowFullId(av.getShowFullId());\r
+ view.setShowFullId(av.getShowJVSuffix());\r
view.setShowIdentity(av.showIdentity);\r
view.setShowQuality(av.showQuality);\r
view.setShowSequenceFeatures(av.showSequenceFeatures);\r
view.setShowText(av.getShowText());\r
view.setWrapAlignment(av.getWrapAlignment());\r
\r
+ if(av.featuresDisplayed!=null)\r
+ {\r
+ jalview.schemabinding.version2.FeatureSettings fs\r
+ = new jalview.schemabinding.version2.FeatureSettings();\r
+\r
+ String [] renderOrder =\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder;\r
+ for(int ro=0; ro<renderOrder.length; ro++)\r
+ {\r
+ Setting setting = new Setting();\r
+ setting.setType(renderOrder[ro]);\r
+ setting.setColour(\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().getColour(renderOrder[ro]).getRGB()\r
+ );\r
+\r
+ setting.setDisplay(\r
+ av.featuresDisplayed.containsKey(renderOrder[ro])\r
+ );\r
+\r
+ fs.addSetting(setting);\r
+\r
+ }\r
+ jms.setFeatureSettings(fs);\r
+\r
+ }\r
+\r
+ if(av.hasHiddenColumns)\r
+ {\r
+ for(int c=0; c<av.getColumnSelection().getHiddenColumns().size(); c++)\r
+ {\r
+ int [] region = (int[]) av.getColumnSelection().getHiddenColumns().elementAt(c);\r
+ HiddenColumns hc = new HiddenColumns();\r
+ hc.setStart(region[0]);\r
+ hc.setEnd(region[1]);\r
+ view.addHiddenColumns(hc);\r
+ }\r
+ }\r
+\r
jms.addViewport(view);\r
\r
+\r
object.setJalviewModelSequence(jms);\r
object.getVamsasModel().addSequenceSet(vamsasSet);\r
\r
}\r
}\r
\r
- static String SetUserColourScheme(jalview.schemes.ColourSchemeI cs,\r
+ String SetUserColourScheme(jalview.schemes.ColourSchemeI cs,\r
Vector userColours, JalviewModelSequence jms)\r
{\r
String id = null;\r
userColours.add(ucs);\r
\r
java.awt.Color[] colours = ucs.getColours();\r
- jalview.binding.UserColours uc = new jalview.binding.UserColours();\r
- jalview.binding.UserColourScheme jbucs = new jalview.binding.UserColourScheme();\r
+ jalview.schemabinding.version2.UserColours uc = new jalview.schemabinding.version2.UserColours();\r
+ jalview.schemabinding.version2.UserColourScheme jbucs = new jalview.schemabinding.version2.UserColourScheme();\r
\r
for (int i = 0; i < colours.length; i++)\r
{\r
- jalview.binding.Colour col = new jalview.binding.Colour();\r
+ jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();\r
col.setRGB(jalview.util.Format.getHexString(colours[i]));\r
jbucs.addColour(col);\r
}\r
return id;\r
}\r
\r
- static jalview.schemes.UserColourScheme GetUserColourScheme(\r
+ jalview.schemes.UserColourScheme GetUserColourScheme(\r
JalviewModelSequence jms, String id)\r
{\r
UserColours[] uc = jms.getUserColours();\r
*\r
* @param file DOCUMENT ME!\r
*/\r
- public static AlignFrame LoadJalviewAlign(String file)\r
+ public AlignFrame LoadJalviewAlign(String file)\r
{\r
- JalviewModel object = new JalviewModel();\r
jalview.gui.AlignFrame af = null;\r
-\r
try\r
{\r
//UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING\r
jarentry = jin.getNextJarEntry();\r
}\r
\r
- if (jarentry != null)\r
+ if (jarentry != null && jarentry.getName().endsWith(".xml"))\r
{\r
InputStreamReader in = new InputStreamReader(jin, "UTF-8");\r
- object = (JalviewModel) object.unmarshal(in);\r
- af = LoadFromObject(object);\r
+ JalviewModel object = new JalviewModel();\r
+\r
+ Unmarshaller unmar = new Unmarshaller(object);\r
+ unmar.setValidation(false);\r
+ object = (JalviewModel) unmar.unmarshal( in );\r
+\r
+ af = LoadFromObject(object, file);\r
entryCount++;\r
}\r
+ else if (jarentry != null)\r
+ {\r
+ //Some other file here.\r
+ entryCount++;\r
+ }\r
}\r
while (jarentry != null);\r
}\r
+ catch(java.net.UnknownHostException ex)\r
+ {\r
+ ex.printStackTrace();\r
+ System.err.println("Couldn't locate Jalview XML file : " +\r
+ ex + "\n");\r
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+ "Couldn't locate " + file,\r
+ "URL not found",\r
+ JOptionPane.WARNING_MESSAGE);\r
+\r
+ }\r
catch (Exception ex)\r
{\r
+ //Is Version 1 Jar file?\r
+ af = new Jalview2XML_V1().LoadJalviewAlign(file);\r
+\r
+ if(af!=null)\r
+ {\r
+ System.out.println("Successfully loaded archive file");\r
+ return af;\r
+ }\r
+ ex.printStackTrace();\r
System.err.println("Exception whilst loading jalview XML file : " +\r
ex + "\n");\r
JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "Couldn't locate " + file,\r
- "URL not found",\r
+ "Error loading " + file,\r
+ "Error loading Jalview file",\r
JOptionPane.WARNING_MESSAGE);\r
\r
}\r
return af;\r
}\r
\r
- static AlignFrame LoadFromObject(JalviewModel object)\r
+ String loadPDBFile(String file, String pdbId)\r
+ {\r
+ System.out.println("load file "+file);\r
+ try\r
+ {\r
+ JarInputStream jin = null;\r
+\r
+ if (file.startsWith("http://"))\r
+ {\r
+ jin = new JarInputStream(new URL(file).openStream());\r
+ }\r
+ else\r
+ {\r
+ jin = new JarInputStream(new FileInputStream(file));\r
+ }\r
+\r
+ JarEntry entry = null;\r
+ do\r
+ {\r
+ entry = jin.getNextJarEntry();\r
+ }\r
+ while (!entry.getName().equals(pdbId));\r
+\r
+ BufferedReader in = new BufferedReader(new InputStreamReader(jin));\r
+ File outFile = File.createTempFile("jalview_pdb", ".txt");\r
+ outFile.deleteOnExit();\r
+ PrintWriter out = new PrintWriter(new FileOutputStream(outFile));\r
+ String data;\r
+\r
+ while ( (data = in.readLine()) != null)\r
+ {\r
+ out.println(data);\r
+ }\r
+ out.close();\r
+ return outFile.getAbsolutePath();\r
+\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+\r
+ AlignFrame LoadFromObject(JalviewModel object, String file)\r
{\r
Vector seqids = new Vector();\r
SequenceSet vamsasSet = object.getVamsasModel().getSequenceSet(0);\r
\r
//////////////////////////////////\r
//LOAD SEQUENCES\r
+ Vector hiddenSeqs = null;\r
jalview.datamodel.Sequence[] jseqs = new jalview.datamodel.Sequence[vamsasSeq.length];\r
JSeq[] JSEQ = object.getJalviewModelSequence().getJSeq();\r
-\r
for (int i = 0; i < vamsasSeq.length; i++)\r
{\r
jseqs[i] = new jalview.datamodel.Sequence(vamsasSeq[i].getName(),\r
vamsasSeq[i].getSequence());\r
+ jseqs[i].setDescription( vamsasSeq[i].getDescription() );\r
\r
+ if(JSEQ[i].getHidden())\r
+ {\r
+ if(hiddenSeqs == null)\r
+ hiddenSeqs = new Vector();\r
+ hiddenSeqs.addElement(jseqs[i]);\r
+ }\r
jseqs[i].setStart(JSEQ[i].getStart());\r
jseqs[i].setEnd(JSEQ[i].getEnd());\r
jseqs[i].setColor(new java.awt.Color(JSEQ[i].getColour()));\r
seqids.add(jseqs[i]);\r
}\r
\r
+ ///SequenceFeatures are added to the DatasetSequence,\r
+ // so we must create the dataset before loading features\r
/////////////////////////////////\r
jalview.datamodel.Alignment al = new jalview.datamodel.Alignment(jseqs);\r
-\r
+ al.setDataset(null);\r
/////////////////////////////////\r
+\r
+\r
+ Hashtable pdbloaded = new Hashtable();\r
+ for (int i = 0; i < vamsasSeq.length; i++)\r
+ {\r
+ if (JSEQ[i].getFeaturesCount() > 0)\r
+ {\r
+ Features[] features = JSEQ[i].getFeatures();\r
+ for (int f = 0; f < features.length; f++)\r
+ {\r
+ jalview.datamodel.SequenceFeature sf\r
+ = new jalview.datamodel.SequenceFeature(features[f].getType(),\r
+ features[f].getDescription(), features[f].getStatus(),\r
+ features[f].getBegin(), features[f].getEnd(),\r
+ features[f].getFeatureGroup());\r
+\r
+ al.getSequenceAt(i).getDatasetSequence().addSequenceFeature(sf);\r
+ }\r
+ }\r
+ if (JSEQ[i].getPdbidsCount() > 0)\r
+ {\r
+ Pdbids[] ids = JSEQ[i].getPdbids();\r
+ for (int p = 0; p < ids.length; p++)\r
+ {\r
+ jalview.datamodel.PDBEntry entry = new jalview.datamodel.PDBEntry();\r
+ entry.setId(ids[p].getId());\r
+ entry.setType(ids[p].getType());\r
+ if (ids[p].getFile() != null)\r
+ {\r
+ if (!pdbloaded.containsKey(ids[p].getFile()))\r
+ {\r
+ String tmppdb = loadPDBFile(file, ids[p].getId());\r
+ entry.setFile(tmppdb);\r
+ pdbloaded.put(ids[p].getId(), tmppdb);\r
+ }\r
+ else\r
+ entry.setFile(pdbloaded.get(ids[p].getId()).toString());\r
+ }\r
+\r
+ al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);\r
+ }\r
+ }\r
+ if(vamsasSeq[i].getDBRefCount()>0)\r
+ {\r
+ for(int d=0; d<vamsasSeq[i].getDBRefCount(); d++)\r
+ {\r
+ jalview.datamodel.DBRefEntry entry =\r
+ new jalview.datamodel.DBRefEntry(\r
+ vamsasSeq[i].getDBRef(d).getSource(),\r
+ vamsasSeq[i].getDBRef(d).getVersion(),\r
+ vamsasSeq[i].getDBRef(d).getAccessionId()\r
+ );\r
+ al.getSequenceAt(i).getDatasetSequence().addDBRef(entry);\r
+ }\r
+\r
+ }\r
+ }\r
+\r
+\r
+\r
+ /////////////////////////////////\r
//////////////////////////////////\r
//LOAD ANNOTATIONS\r
+ boolean hideQuality = true,\r
+ hideConservation = true,\r
+ hideConsensus = true;\r
+\r
if (vamsasSet.getAnnotation() != null)\r
{\r
Annotation[] an = vamsasSet.getAnnotation();\r
\r
for (int i = 0; i < an.length; i++)\r
{\r
+ if (an[i].getLabel().equals("Quality"))\r
+ {\r
+ hideQuality = false;\r
+ continue;\r
+ }\r
+ else if(an[i].getLabel().equals("Conservation"))\r
+ {\r
+ hideConservation = false;\r
+ continue;\r
+ }\r
+ else if(an[i].getLabel().equals("Consensus"))\r
+ {\r
+ hideConsensus = false;\r
+ continue;\r
+ }\r
+\r
AnnotationElement[] ae = an[i].getAnnotationElement();\r
jalview.datamodel.Annotation[] anot = new jalview.datamodel.Annotation[al.getWidth()];\r
\r
{\r
anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa].getDisplayCharacter(),\r
ae[aa].getDescription(),\r
- ae[aa].getSecondaryStructure().charAt(0),\r
+ ae[aa].getSecondaryStructure().length()==0?' ':ae[aa].getSecondaryStructure().charAt(0),\r
ae[aa].getValue());\r
+ anot[ae[aa].getPosition()].colour = new java.awt.Color( ae[aa].getColour() );\r
}\r
\r
jalview.datamodel.AlignmentAnnotation jaa = null;\r
\r
if (an[i].getGraph())\r
{\r
- jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
- an[i].getDescription(), anot, 0, 0, 1);\r
+ jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
+ an[i].getDescription(), anot, 0, 0,\r
+ an[i].getGraphType());\r
+\r
+ jaa.graphGroup = an[i].getGraphGroup();\r
+\r
+ if (an[i].getThresholdLine() != null)\r
+ {\r
+ jaa.setThreshold(new jalview.datamodel.GraphLine(\r
+ an[i].getThresholdLine().getValue(),\r
+ an[i].getThresholdLine().getLabel(),\r
+ new java.awt.Color(an[i].getThresholdLine().getColour()))\r
+ );\r
+\r
+ }\r
+\r
}\r
else\r
{\r
an[i].getDescription(), anot);\r
}\r
\r
+ if(an[i].getSequenceRef()!=null)\r
+ {\r
+ jaa.createSequenceMapping(\r
+ al.findName(an[i].getSequenceRef()), 1\r
+ );\r
+ al.findName(an[i].getSequenceRef()).addAlignmentAnnotation(jaa);\r
+ }\r
+\r
al.addAnnotation(jaa);\r
}\r
}\r
\r
- /////////////////////////////////\r
- // LOAD VIEWPORT\r
- Viewport[] views = jms.getViewport();\r
- Viewport view = views[0]; // DEAL WITH MULTIPLE VIEWPORTS LATER\r
-\r
- AlignFrame af = new AlignFrame(al);\r
\r
// af.changeColour() );\r
/////////////////////////\r
groups[i].getColour());\r
}\r
\r
- if (cs instanceof ResidueColourScheme)\r
- {\r
- ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
- }\r
- else if (cs instanceof ScoreColourScheme)\r
- {\r
- ((ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
- }\r
+ if(cs!=null)\r
+ cs.setThreshold(groups[i].getPidThreshold(), true);\r
}\r
\r
Vector seqs = new Vector();\r
if (groups[i].getConsThreshold() != 0)\r
{\r
jalview.analysis.Conservation c = new jalview.analysis.Conservation("All",\r
- ResidueProperties.propHash, 3, sg.sequences, 0,\r
+ ResidueProperties.propHash, 3, sg.getSequences(false), 0,\r
sg.getWidth() - 1);\r
c.calculate();\r
c.verdict(false, 25);\r
- cs = new ConservationColourScheme(c, cs);\r
- sg.cs = cs;\r
+ sg.cs.setConservation(c);\r
}\r
\r
al.addGroup(sg);\r
}\r
}\r
\r
- Desktop.addInternalFrame(af, view.getTitle(),\r
- AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);\r
+\r
+ /////////////////////////////////\r
+ // LOAD VIEWPORT\r
+ Viewport[] views = jms.getViewport();\r
+ Viewport view = views[0]; // DEAL WITH MULTIPLE VIEWPORTS LATER\r
+\r
+\r
+ AlignFrame af = new AlignFrame(al);\r
+\r
+ if(hiddenSeqs!=null)\r
+ {\r
+ for(int s=0; s<JSEQ.length; s++)\r
+ {\r
+ for(int r=0; r<JSEQ[s].getHiddenSequencesCount(); r++)\r
+ {\r
+ al.getSequenceAt(s).addHiddenSequence(\r
+ al.getSequenceAt( JSEQ[s].getHiddenSequences(r) )\r
+ );\r
+ }\r
+ }\r
+\r
+ for(int s=0; s<hiddenSeqs.size(); s++)\r
+ {\r
+ af.viewport.hideSequence(\r
+ (jalview.datamodel.SequenceI)hiddenSeqs.elementAt(s));\r
+ }\r
+ }\r
+\r
+\r
+ if(hideConsensus || hideQuality || hideConservation)\r
+ {\r
+ int hSize = al.getAlignmentAnnotation().length;\r
+ for (int h = 0; h < hSize; h++)\r
+ {\r
+ if (\r
+ (hideConsensus &&\r
+ al.getAlignmentAnnotation()[h].label.equals("Consensus"))\r
+ ||\r
+ (hideQuality &&\r
+ al.getAlignmentAnnotation()[h].label.equals("Quality"))\r
+ ||\r
+ (hideConservation &&\r
+ al.getAlignmentAnnotation()[h].label.equals("Conservation")))\r
+ {\r
+ al.deleteAnnotation(al.getAlignmentAnnotation()[h]);\r
+ hSize--;\r
+ h--;\r
+ }\r
+ }\r
+ af.alignPanel.adjustAnnotationHeight();\r
+ }\r
+\r
af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),\r
view.getHeight());\r
af.viewport.setStartRes(view.getStartRes());\r
af.viewport.setStartSeq(view.getStartSeq());\r
+ af.viewport.setShowAnnotation(view.getShowAnnotation());\r
af.viewport.showConservation = view.getShowConservation();\r
af.viewport.showQuality = view.getShowQuality();\r
af.viewport.showIdentity = view.getShowIdentity();\r
af.viewport.setConservationSelected(view.getConservationSelected());\r
af.conservationMenuItem.setSelected(view.getConservationSelected());\r
\r
- af.viewport.setShowFullId(view.getShowFullId());\r
- af.fullSeqId.setSelected(view.getShowFullId());\r
+ af.viewport.setShowJVSuffix(view.getShowFullId());\r
+ af.seqLimits.setSelected(view.getShowFullId());\r
\r
af.viewport.setFont(new java.awt.Font(view.getFontName(),\r
view.getFontStyle(), view.getFontSize()));\r
{\r
cs = GetUserColourScheme(jms, view.getBgColour());\r
}\r
- else\r
+ else if(view.getBgColour().startsWith("Annotation"))\r
{\r
- cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
- }\r
+ //int find annotation\r
+ for (int i = 0; i < af.viewport.alignment.getAlignmentAnnotation().length; i++)\r
+ {\r
+ if (af.viewport.alignment.getAlignmentAnnotation()[i].label.\r
+ equals(view.getAnnotationColours().getAnnotation()))\r
+ {\r
+ if (af.viewport.alignment.getAlignmentAnnotation()[i].\r
+ getThreshold() == null)\r
+ {\r
+ af.viewport.alignment.getAlignmentAnnotation()[i].\r
+ setThreshold(\r
+ new jalview.datamodel.GraphLine(\r
+ view.getAnnotationColours().getThreshold(),\r
+ "Threshold", java.awt.Color.black)\r
+\r
+ );\r
+ }\r
+\r
+\r
+ if (view.getAnnotationColours().getColourScheme().equals(\r
+ "None"))\r
+ {\r
+ cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMinColour()),\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMaxColour()),\r
+ view.getAnnotationColours().getAboveThreshold());\r
+ }\r
+ else if (view.getAnnotationColours().getColourScheme().\r
+ startsWith("ucs"))\r
+ {\r
+ cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ GetUserColourScheme(jms, view.getAnnotationColours().\r
+ getColourScheme()),\r
+ view.getAnnotationColours().getAboveThreshold()\r
+ );\r
+ }\r
+ else\r
+ {\r
+ cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ ColourSchemeProperty.getColour(al,\r
+ view.getAnnotationColours().getColourScheme()),\r
+ view.getAnnotationColours().getAboveThreshold()\r
+ );\r
+ }\r
+\r
+ // Also use these settings for all the groups\r
+ if (al.getGroups() != null)\r
+ for (int g = 0; g < al.getGroups().size(); g++)\r
+ {\r
+ jalview.datamodel.SequenceGroup sg\r
+ = (jalview.datamodel.SequenceGroup)al.getGroups().elementAt(g);\r
+\r
+ if(sg.cs == null)\r
+ continue;\r
\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- ((ConservationColourScheme) cs).inc = view.getConsThreshold();\r
- }\r
\r
- if (cs instanceof ResidueColourScheme)\r
+ /* if (view.getAnnotationColours().getColourScheme().equals("None"))\r
+ {\r
+ sg.cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMinColour()),\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMaxColour()),\r
+ view.getAnnotationColours().getAboveThreshold());\r
+ }\r
+ else*/\r
+ {\r
+ sg.cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ sg.cs,\r
+ view.getAnnotationColours().getAboveThreshold()\r
+ );\r
+ }\r
+\r
+ }\r
+\r
+\r
+ break;\r
+ }\r
+\r
+ }\r
+ }\r
+ else\r
{\r
- ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold());\r
+ cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
}\r
- else if (cs instanceof ScoreColourScheme)\r
+\r
+ if(cs!=null)\r
{\r
- ((ScoreColourScheme) cs).setThreshold(view.getPidThreshold());\r
+ cs.setThreshold(view.getPidThreshold(), true);\r
+ cs.setConsensus(af.viewport.vconsensus);\r
}\r
}\r
\r
+ af.setColourSelected(view.getBgColour());\r
af.viewport.setGlobalColourScheme(cs);\r
-\r
af.viewport.setColourAppliesToAllGroups(false);\r
- af.changeColour(af.viewport.getGlobalColourScheme());\r
+ af.changeColour(cs);\r
+ if (view.getConservationSelected() && cs!=null)\r
+ {\r
+ cs.setConservationInc(view.getConsThreshold());\r
+ }\r
+\r
af.viewport.setColourAppliesToAllGroups(true);\r
\r
if (view.getShowSequenceFeatures())\r
{\r
- af.viewport.showSequenceFeatures = true;\r
- af.sequenceFeatures.setSelected(true);\r
- new SequenceFeatureFetcher(al, af.alignPanel);\r
- al.featuresAdded = true;\r
+ af.viewport.showSequenceFeatures = true;\r
+ af.showSeqFeatures.setSelected(true);\r
+ }\r
+\r
+ if(jms.getFeatureSettings()!=null)\r
+ {\r
+ af.viewport.featuresDisplayed = new Hashtable();\r
+ String [] renderOrder = new String[jms.getFeatureSettings().getSettingCount()];\r
+ for(int fs=0; fs<jms.getFeatureSettings().getSettingCount(); fs++)\r
+ {\r
+ Setting setting = jms.getFeatureSettings().getSetting(fs);\r
+\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(setting.getType(),\r
+ new java.awt.Color(setting.getColour()));\r
+\r
+ renderOrder[fs] = setting.getType();\r
+\r
+ if(setting.getDisplay())\r
+ af.viewport.featuresDisplayed.put(\r
+ setting.getType(), new Integer(setting.getColour()));\r
+ }\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder = renderOrder;\r
+ }\r
+\r
+ if (view.getHiddenColumnsCount() > 0)\r
+ {\r
+ for (int c = 0; c < view.getHiddenColumnsCount(); c++)\r
+ {\r
+ af.viewport.hideColumns(\r
+ view.getHiddenColumns(c).getStart(),\r
+ view.getHiddenColumns(c).getEnd()+1\r
+ );\r
+ }\r
}\r
\r
+\r
+ Desktop.addInternalFrame(af, view.getTitle(),\r
+ view.getWidth(), view.getHeight());\r
+\r
//LOAD TREES\r
///////////////////////////////////////\r
if (jms.getTreeCount() > 0)\r
{\r
for (int t = 0; t < jms.getTreeCount(); t++)\r
{\r
+\r
Tree tree = jms.getTree(t);\r
\r
TreePanel tp = af.ShowNewickTree(new jalview.io.NewickFile(\r
- tree.getNewick()), tree.getTitle());\r
-\r
- tp.setBounds(tree.getXpos(), tree.getYpos(),\r
- tree.getWidth(), tree.getHeight());\r
+ tree.getNewick()), tree.getTitle(),\r
+ tree.getWidth(), tree.getHeight(),\r
+ tree.getXpos(), tree.getYpos());\r
\r
tp.fitToWindow.setState(tree.getFitToWindow());\r
tp.fitToWindow_actionPerformed(null);\r
- tp.treeCanvas.fontSize = tree.getFontSize();\r
- tp.fontSize.setText("Font Size - " + tree.getFontSize());\r
- tp.placeholdersMenu.setState(tree.getMarkUnlinked());\r
- tp.placeholdersMenu_actionPerformed(null);\r
- tp.bootstrapMenu.setState(tree.getShowBootstrap());\r
- tp.bootstrapMenu_actionPerformed(null);\r
- tp.distanceMenu.setState(tree.getShowDistances());\r
- tp.distanceMenu_actionPerformed(null);\r
+\r
+ if(tree.getFontName()!=null)\r
+ tp.setTreeFont(new java.awt.Font(tree.getFontName(),\r
+ tree.getFontStyle(),\r
+ tree.getFontSize()));\r
+ else\r
+ tp.setTreeFont(new java.awt.Font(view.getFontName(),\r
+ view.getFontStyle(),\r
+ tree.getFontSize()));\r
+\r
+ tp.showPlaceholders(tree.getMarkUnlinked());\r
+ tp.showBootstrap(tree.getShowBootstrap());\r
+ tp.showDistances(tree.getShowDistances());\r
+\r
tp.treeCanvas.threshold = tree.getThreshold();\r
\r
if (tree.getCurrentTree())\r
af.viewport.setCurrentTree(tp.getTree());\r
}\r
+\r
}\r
catch (Exception ex)\r
{\r
ex.printStackTrace();\r
}\r
+\r
}\r
+\r
return af;\r
}\r
}\r
+\r