- private void processPdbFileWithJmol(List<SequenceI> prot)
- throws Exception
- {
- try
- {
- Class cl = Class.forName("jalview.ext.jmol.PDBFileWithJmol");
- if (cl != null)
- {
- final Constructor constructor = cl.getConstructor(new Class[]
- { FileParse.class });
- final Object[] args = new Object[]
- { new FileParse(getDataName(), type) };
- Object jmf = constructor.newInstance(args);
- Alignment al = new Alignment((SequenceI[]) cl.getMethod(
- "getSeqsAsArray", new Class[]
- {}).invoke(jmf));
- cl.getMethod("addAnnotations", new Class[]
- { AlignmentI.class }).invoke(jmf, al);
- for (SequenceI sq : al.getSequences())
- {
- if (sq.getDatasetSequence() != null)
- {
- sq.getDatasetSequence().getPDBId().clear();
- }
- else
- {
- sq.getPDBId().clear();
- }
- }
- replaceAndUpdateChains(prot, al, AlignSeq.PEP, false);
- }
- } catch (ClassNotFoundException q)
- {
- }
- }
-
- private void replaceAndUpdateChains(List<SequenceI> prot,
- AlignmentI al, String pep, boolean b)
- {
- List<List<? extends Object>> replaced = AlignSeq
- .replaceMatchingSeqsWith(seqs, annotations, prot, al, 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(List<SequenceI> rna)
- throws Exception
- {
- // System.out.println("this is a PDB format and RNA sequence");
- // note: we use reflection here so that the applet can compile and run
- // without the HTTPClient bits and pieces needed for accessing Annotate3D
- // web service
- try
- {
- Class cl = Class.forName("jalview.ws.jws1.Annotate3D");
- if (cl != null)
- {
- // TODO: use the PDB ID of the structure if one is available, to save
- // bandwidth and avoid uploading the whole structure to the service
- Object annotate3d = cl.getConstructor(new Class[]
- {}).newInstance(new Object[]
- {});
- AlignmentI al = ((AlignmentI) cl.getMethod("getRNAMLFor",
- new Class[]
- { FileParse.class }).invoke(annotate3d, new Object[]
- { new FileParse(getDataName(), type) }));
- for (SequenceI sq : al.getSequences())
- {
- if (sq.getDatasetSequence() != null)
- {
- if (sq.getDatasetSequence().getPDBId() != null)
- {
- sq.getDatasetSequence().getPDBId().clear();
- }
- }
- else
- {
- if (sq.getPDBId() != null)
- {
- sq.getPDBId().clear();
- }
- }
- }
- replaceAndUpdateChains(rna, al, AlignSeq.DNA, false);
- }
- } catch (ClassNotFoundException x)
- {
- // ignore classnotfounds - occurs in applet
- }
- ;
- }
-
- /**
- * make a friendly ID string.
- *
- * @param dataName
- * @return truncated dataName to after last '/'
- */
- private String safeName(String dataName)
- {
- int p = 0;
- while ((p = dataName.indexOf("/")) > -1 && p < dataName.length())
- {
- dataName = dataName.substring(p + 1);
- }
- return dataName;
- }
-
- public void makeResidueList()
- {
- for (int i = 0; i < chains.size(); i++)
- {
- chains.elementAt(i).makeResidueList(visibleChainAnnotation);
- }
- }
-
- public void makeCaBondList()
- {
- for (int i = 0; i < chains.size(); i++)
- {
- chains.elementAt(i).makeCaBondList();
- }
- }
-
- public PDBChain findChain(String id)
- {
- for (int i = 0; i < chains.size(); i++)
- {
- if (chains.elementAt(i).id.equals(id))
- {
- return chains.elementAt(i);
- }
- }
-
- return null;
- }
-
- public void setChargeColours()
- {
- for (int i = 0; i < chains.size(); i++)
- {
- chains.elementAt(i).setChargeColours();
- }
- }
-
- public void setColours(jalview.schemes.ColourSchemeI cs)
- {
- for (int i = 0; i < chains.size(); i++)
- {
- chains.elementAt(i).setChainColours(cs);
- }
- }
-
- public void setChainColours()
- {
- for (int i = 0; i < chains.size(); i++)
- {
- // divide by zero --> infinity --> 255 ;-)
- chains.elementAt(i).setChainColours(
- Color.getHSBColor(1.0f / i, .4f, 1.0f));
- }
- }
-
- public static boolean isRNA(SequenceI seq)
- {
- for (char c : seq.getSequence())
- {
- if ((c != 'A') && (c != 'C') && (c != 'G') && (c != 'U'))
- {
- return false;
- }
- }
-
- return true;
-
- }