001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 * created at Sep 18, 2013
021 * Author: ap3
022 */
023
024package demo;
025
026import org.biojava.nbio.structure.Structure;
027import org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol;
028import org.biojava.nbio.structure.StructureIO;
029import org.biojava.nbio.structure.validation.*;
030
031import javax.xml.bind.JAXBContext;
032import javax.xml.bind.Unmarshaller;
033import java.io.InputStream;
034import java.math.BigDecimal;
035import java.math.BigInteger;
036import java.util.List;
037import java.util.zip.GZIPInputStream;
038
039public class DemoShowValidationResults {
040
041        public static void main(String[] args){
042                //String pdbId ="3zjr";
043                String pdbId ="3vtq";
044                showPdbValidation(pdbId);
045        }
046
047        private static void showPdbValidation(String pdbId) {
048                try {
049                        JAXBContext ctx = JAXBContext.newInstance(new Class[] {WwPDBValidationInformation.class});
050
051                        Unmarshaller um = ctx.createUnmarshaller();
052
053                        InputStream inStream = new GZIPInputStream(DemoShowValidationResults.class.getResourceAsStream("/"+pdbId+"-valdata.xml.gz"));
054
055                        WwPDBValidationInformation validationReport = (WwPDBValidationInformation) um.unmarshal(inStream);
056
057                        Entry entry = validationReport.getEntry();
058
059                        System.out.println(pdbId + " " + entry.getPDBRevisionNumber() +
060                                        "\t Rfree: " + entry.getDCCRfree() +
061                                        "\t Clashscore " + entry.getClashscore() +
062                                        "\t % Ramachandran outliers: "  + entry.getPercentRamaOutliers() +
063                                        "\t % RSRC outliers: " + entry.getPercentRSRZOutliers() );
064
065
066                        StructureAlignmentJmol jmolPanel = new StructureAlignmentJmol();
067
068                        Structure s = StructureIO.getStructure(pdbId);
069
070                        jmolPanel.setStructure(s);
071
072                        jmolPanel.evalString("select *; color grey ; cartoon off ; ");
073
074                        for (ModelledSubgroup subgroup:  validationReport.getModelledSubgroup()) {
075
076                                List<Clash> clashes = subgroup.getClash();
077
078                                String chainId = subgroup.getChain();
079                                //String resname = subgroup.getResname();
080                                String iCode = subgroup.getIcode();
081                                BigInteger resnum = subgroup.getResnum();
082                                //String altcode = subgroup.getAltcode();
083
084
085                                String pos = resnum.toString() ;
086                                if ( iCode !=null && iCode.length()>0 && (! iCode.equals(" ")))
087                                        pos +="^" + iCode;
088                                pos +=":" + chainId;
089
090                                BigDecimal base = new BigDecimal(0.5);
091
092                                for (Clash clash : clashes){
093                                        String clashatom = clash.getAtom();
094                                        BigDecimal clashmag = clash.getClashmag();
095                                        // pos1 icode A chain X should become:
096                                        // 1^A:X
097                                        // [MET]508:A.CA/1 #3918
098                                        // insertion code: [ASP]1^A:A.CA/1 #2
099
100                                        String clashj = pos + "." + clashatom;
101                                        String jmols = " select " + clashj + "; color red; spacefill " + (base.add(clashmag)) + ";" ;
102                                        System.out.println(jmols + " " + clashmag);
103                                        jmolPanel.evalString(jmols);
104                                }
105
106
107                                for (AngleOutlier angleout : subgroup.getAngleOutlier()) {
108                                        String atom0 = angleout.getAtom0();
109                                        String atom1 = angleout.getAtom1();
110                                        String atom2 = angleout.getAtom2();
111
112                                        String anglej = "select " + pos + "." + atom0+"," +pos+"." + atom1 +"," + pos +"." + atom2+"; color wireframe blue; wireframe 0.5;";
113                                        //System.out.println(anglej);
114                                        jmolPanel.evalString(anglej);
115                                }
116
117                                for (BondOutlier bondout : subgroup.getBondOutlier()){
118                                        String atom0 = bondout.getAtom0();
119                                        String atom1 = bondout.getAtom1();
120                                        String bondj = "select " + pos + "." + atom0+"," +pos+"." + atom1 +"; color wireframe green; wireframe 0.5;";
121                                        jmolPanel.evalString(bondj);
122
123                                }
124                        }
125
126
127                } catch (Exception e){
128                        e.printStackTrace();
129
130                }
131
132        }
133
134}