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
features.setBegin(sf[index].getBegin());\r
features.setEnd(sf[index].getEnd());\r
features.setDescription(sf[index].getDescription());\r
- features.setStatus(sf[index].getStatus());\r
features.setType(sf[index].getType());\r
features.setFeatureGroup(sf[index].getFeatureGroup());\r
jseq.addFeatures(features);\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
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
\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
*/\r
public AlignFrame LoadJalviewAlign(String file)\r
{\r
-\r
jalview.gui.AlignFrame af = null;\r
-\r
try\r
{\r
//UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING\r
for (int i = 0; i < entryCount; i++)\r
{\r
jarentry = jin.getNextJarEntry();\r
+ }\r
\r
- }\r
-\r
-\r
- class NoDescIDResolver implements IDResolver\r
- {\r
- public Object resolve(String idref)\r
- {\r
- System.out.println(idref+" used");\r
- return null;\r
- }\r
- }\r
-\r
-\r
- if (jarentry != null)\r
+ if (jarentry != null && jarentry.getName().endsWith(".xml"))\r
{\r
InputStreamReader in = new InputStreamReader(jin, "UTF-8");\r
JalviewModel object = new JalviewModel();\r
unmar.setValidation(false);\r
object = (JalviewModel) unmar.unmarshal( in );\r
\r
- af = LoadFromObject(object);\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
return af;\r
}\r
\r
- 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
for (int i = 0; i < vamsasSeq.length; i++)\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
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
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
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
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
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