|
| 1 | +/* |
| 2 | + * BioJava development code |
| 3 | + * |
| 4 | + * This code may be freely distributed and modified under the |
| 5 | + * terms of the GNU Lesser General Public Licence. This should |
| 6 | + * be distributed with the code. If you do not have a copy, |
| 7 | + * see: |
| 8 | + * |
| 9 | + * http://www.gnu.org/copyleft/lesser.html |
| 10 | + * |
| 11 | + * Copyright for this code is held jointly by the individual |
| 12 | + * authors. These should be listed in @author doc comments. |
| 13 | + * |
| 14 | + * For more information on the BioJava project and its aims, |
| 15 | + * or to join the biojava-l mailing list, visit the home page |
| 16 | + * at: |
| 17 | + * |
| 18 | + * http://www.biojava.org/ |
| 19 | + * |
| 20 | + * Created on Jul 6, 2016 |
| 21 | + * Author: blivens |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +package org.biojava.http.compute; |
| 26 | + |
| 27 | +import java.util.List; |
| 28 | + |
| 29 | +import org.biojava.nbio.structure.Atom; |
| 30 | +import org.biojava.nbio.structure.Structure; |
| 31 | +import org.biojava.nbio.structure.StructureException; |
| 32 | +import org.biojava.nbio.structure.align.multiple.MultipleAlignment; |
| 33 | +import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentDisplay; |
| 34 | +import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentTools; |
| 35 | +import org.biojava.nbio.structure.symmetry.internal.CeSymmResult; |
| 36 | +import org.slf4j.Logger; |
| 37 | +import org.slf4j.LoggerFactory; |
| 38 | + |
| 39 | +import spark.ResponseTransformer; |
| 40 | + |
| 41 | +public class CeSymmPDBTransformer implements ResponseTransformer { |
| 42 | + public static Logger logger = LoggerFactory.getLogger(CeSymmPDBTransformer.class); |
| 43 | + |
| 44 | + public CeSymmPDBTransformer() { |
| 45 | + super(); |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + public String render(Object model) { |
| 50 | + CeSymmResult result = (CeSymmResult) model; |
| 51 | + |
| 52 | + try { |
| 53 | + MultipleAlignment multAln = result.getMultipleAlignment(); |
| 54 | + List<Atom[]> rotatedAtoms = MultipleAlignmentDisplay.getRotatedAtoms(multAln ); |
| 55 | + Structure artificial = MultipleAlignmentTools.toMultimodelStructure(multAln, rotatedAtoms); |
| 56 | + return artificial.toPDB(); |
| 57 | + } catch (StructureException e) { |
| 58 | + logger.error("error rendering CeSymm PDB",e); |
| 59 | + return null; |
| 60 | + } |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments