Skip to content

Commit

Permalink
Remove introduced Point_Type and replace with a map, add test on 1CRN.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Apr 11, 2019
1 parent 05dd6e1 commit e96ec83
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

import javax.vecmath.Point3d;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* A class representing the solvent accessible surface area surface of a molecule.
Expand Down Expand Up @@ -119,8 +122,8 @@ private void init() {
for (IAtom atom : atoms) {
if (atom.getPoint3d() == null)
throw new IllegalArgumentException("One or more atoms had no 3D coordinate set");
}
}

// get r_f and geometric center
Point3d cp = new Point3d(0, 0, 0);
double maxRadius = 0;
Expand Down Expand Up @@ -165,7 +168,7 @@ private void init() {
logger.info("Obtained points, areas and volumes");

}

/**
* Get an array of all the points on the molecular surface.
*
Expand All @@ -187,24 +190,20 @@ public Point3d[] getAllSurfacePoints() {
}
return (ret);
}

public ArrayList<Point_Type> getAllPointswithAtomType() {
int npt = 0;
for (List<Point3d> surfPoint : this.surfPoints)
npt += surfPoint.size();
ArrayList<Point_Type> point_types = new ArrayList<Point_Type>(npt);
int j = 0;

/**
* Get the map from atom to surface points. If an atom does not appear in
* the map it is buried. Atoms may share surface points with other atoms.
*
* @return surface atoms and associated points on the surface
*/
public Map<IAtom, List<Point3d>> getAtomSurfaceMap() {
Map<IAtom,List<Point3d>> map = new HashMap<>();
for (int i = 0; i < this.surfPoints.length; i++) {
List<Point3d> arl = this.surfPoints[i];
for (Point3d p : arl) {
Point_Type point_type = new Point_Type();
point_type.setAtom(this.atoms[i].getAtomicNumber());
point_type.setCoord(p);
point_types.add(point_type);
j++;
}
if (!this.surfPoints[i].isEmpty())
map.put(this.atoms[i], Collections.unmodifiableList(this.surfPoints[i]));
}
return (point_types);
return map;
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2019 The Chemistry Development Kit (CDK) project
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

package org.openscience.cdk.geometry.surface;

import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.io.PDBReader;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;

import javax.vecmath.Point3d;
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.junit.Assert.assertThat;

public class NumericalSurfaceTest {

@Test
public void testCranbinSurface() throws Exception {
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance();
IChemFile chemFile;
String path = "/data/pdb/1crn.pdb";
try (InputStream in = getClass().getResourceAsStream(path);
PDBReader pdbr = new PDBReader(in)) {
chemFile = pdbr.read(bldr.newInstance(IChemFile.class));
}
IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
NumericalSurface surface = new NumericalSurface(mol);
Map<IAtom, List<Point3d>> map = surface.getAtomSurfaceMap();
assertThat(map.size(), CoreMatchers.is(222));
assertThat(mol.getAtomCount(), CoreMatchers.is(327));
}

}

0 comments on commit e96ec83

Please sign in to comment.