X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBfile.java;h=ebc52aaf0aa0643410590de2c330fd5611782160;hb=1f6504bd0b7187c99cd4a2551c15e854d14583b5;hp=0934fdb6058f0ade20fcf6ac489028847328b6e7;hpb=6d7ab37f37b09174ec61fee301aed6057ef86605;p=jalview.git diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index 0934fdb..ebc52aa 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -20,17 +20,15 @@ */ package MCview; -import jalview.analysis.AlignSeq; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.AlignmentI; +import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; +import jalview.io.DataSourceType; import jalview.io.FileParse; import jalview.io.StructureFile; import jalview.util.MessageManager; import java.io.IOException; -import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; @@ -44,35 +42,29 @@ public class PDBfile extends StructureFile boolean predictSecondaryStructure, boolean externalSecStr) { super(); - this.visibleChainAnnotation = addAlignmentAnnotations; - this.predictSecondaryStructure = predictSecondaryStructure; - this.externalSecondaryStructure = externalSecStr; + addSettings(addAlignmentAnnotations, predictSecondaryStructure, + externalSecStr); } - public PDBfile(boolean addAlignmentAnnotations, - boolean predictSecondaryStructure, boolean externalSecStr, - String file, String protocol) throws IOException + public PDBfile(boolean addAlignmentAnnotations, boolean predictSecStr, + boolean externalSecStr, String dataObject, + DataSourceType sourceType) throws IOException { - super(false, file, protocol); - this.visibleChainAnnotation = addAlignmentAnnotations; - this.predictSecondaryStructure = predictSecondaryStructure; - this.externalSecondaryStructure = externalSecStr; + super(false, dataObject, sourceType); + addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr); doParse(); } - public PDBfile(boolean addAlignmentAnnotations, - boolean predictSecondaryStructure, boolean externalSecStr, - FileParse source) throws IOException + public PDBfile(boolean addAlignmentAnnotations, boolean predictSecStr, + boolean externalSecStr, FileParse source) throws IOException { super(false, source); - this.visibleChainAnnotation = addAlignmentAnnotations; - this.predictSecondaryStructure = predictSecondaryStructure; - this.externalSecondaryStructure = externalSecStr; + addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr); doParse(); } @Override - public String print() + public String print(SequenceI[] seqs, boolean jvSuffix) { return null; } @@ -80,6 +72,7 @@ public class PDBfile extends StructureFile @Override public void parse() throws IOException { + setDbRefType(DBRefSource.PDB); // TODO set the filename sensibly - try using data source name. setId(safeName(getDataName())); @@ -152,7 +145,7 @@ public class PDBfile extends StructureFile Atom tmpatom = new Atom(line); try { - tmpchain = findChain(tmpatom.chain); + tmpchain = findChain(tmpatom.chain); if (tmpatom.resNumIns.trim().equals(lastID)) { // phosphorylated protein - seen both CA and P.. @@ -191,14 +184,13 @@ public class PDBfile extends StructureFile } if (predictSecondaryStructure) { - predictSecondaryStructure(rna, prot); + addSecondaryStructure(rna, prot); } } catch (OutOfMemoryError er) { System.out.println("OUT OF MEMORY LOADING PDB FILE"); - throw new IOException( - MessageManager - .getString("exception.outofmemory_loading_pdb_file")); + throw new IOException(MessageManager + .getString("exception.outofmemory_loading_pdb_file")); } catch (NumberFormatException ex) { if (line != null) @@ -211,50 +203,6 @@ public class PDBfile extends StructureFile } /** - * Predict secondary structure for RNA and/or protein sequences and add as - * annotations - * - * @param rnaSequences - * @param proteinSequences - */ - protected void predictSecondaryStructure(List rnaSequences, - List proteinSequences) - { - /* - * Currently using Annotate3D for RNA, but only if the 'use external - * prediction' flag is set - */ - if (externalSecondaryStructure && rnaSequences.size() > 0) - { - try - { - processPdbFileWithAnnotate3d(rnaSequences); - } catch (Exception x) - { - System.err.println("Exceptions when dealing with RNA in pdb file"); - x.printStackTrace(); - - } - } - - /* - * Currently using JMol PDB parser for peptide - */ - if (proteinSequences.size() > 0) - { - try - { - processPdbFileWithJmol(proteinSequences); - } catch (Exception x) - { - System.err - .println("Exceptions from Jmol when processing data in pdb file"); - x.printStackTrace(); - } - } - } - - /** * Process a parsed chain to construct and return a Sequence, and add it to * the list of sequences parsed. * @@ -278,8 +226,8 @@ public class PDBfile extends StructureFile public static String relocateCalcId(String calcId, Hashtable alreadyLoadedPDB) throws Exception { - int s = CALC_ID_PREFIX.length(), end = calcId - .indexOf(CALC_ID_PREFIX, s); + int s = CALC_ID_PREFIX.length(), + end = calcId.indexOf(CALC_ID_PREFIX, s); String between = calcId.substring(s, end - 1); return CALC_ID_PREFIX + alreadyLoadedPDB.get(between) + ":" + calcId.substring(end); @@ -306,39 +254,4 @@ public class PDBfile extends StructureFile } } - private void processPdbFileWithJmol(List prot) - throws Exception - { - try - { - - Class cl = Class.forName("jalview.ext.jmol.JmolParser"); - 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); - AlignmentI 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().getAllPDBEntries().clear(); - } - else - { - sq.getAllPDBEntries().clear(); - } - } - replaceAndUpdateChains(prot, al, AlignSeq.PEP, false); - } - } catch (ClassNotFoundException q) - { - } - } }