Skip to content

Commit 95c0ffc

Browse files
committed
Addressing review comments
1 parent 849d2b0 commit 95c0ffc

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.Serializable;
2929
import java.util.Arrays;
3030
import java.util.Locale;
31+
import java.util.Objects;
3132

3233

3334
/**
@@ -73,9 +74,12 @@ public BoundingBox(BoundingBox bb) {
7374
* Constructs a BoundingBox by calculating maxs and mins of given array of atoms.
7475
* @param atoms the atom array
7576
* @throws IllegalArgumentException if atom array is empty
77+
* @throws NullPointerException if input is null
7678
*/
7779
public BoundingBox (Point3d[] atoms) {
7880

81+
Objects.requireNonNull(atoms);
82+
7983
if (atoms.length==0)
8084
throw new IllegalArgumentException("Empty list of atoms is not allowed for BoundingBox construction");
8185

@@ -103,9 +107,12 @@ public BoundingBox (Point3d[] atoms) {
103107
* Given a set of bounding boxes returns a bounding box that bounds all of them.
104108
* @param boxes an array of bounding boxes
105109
* @throws IllegalArgumentException if input array is empty
110+
* @throws NullPointerException if input is null
106111
*/
107112
public BoundingBox(BoundingBox[] boxes) {
108113

114+
Objects.requireNonNull(boxes);
115+
109116
if (boxes.length==0)
110117
throw new IllegalArgumentException("Empty list of bounding boxes is not allowed for BoundingBox construction");
111118

biojava-structure/src/main/java/org/biojava/nbio/structure/contact/InterfaceFinder.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package org.biojava.nbio.structure.contact;
22

3-
import org.biojava.nbio.structure.*;
3+
import org.biojava.nbio.structure.Atom;
4+
import org.biojava.nbio.structure.Calc;
5+
import org.biojava.nbio.structure.Chain;
6+
import org.biojava.nbio.structure.Group;
7+
import org.biojava.nbio.structure.Structure;
8+
import org.biojava.nbio.structure.StructureTools;
49
import org.biojava.nbio.structure.xtal.CrystalTransform;
510
import org.biojava.nbio.structure.xtal.SpaceGroup;
611

712
import javax.vecmath.Point3d;
813
import java.util.ArrayList;
9-
import java.util.Iterator;
14+
import java.util.Collection;
1015
import java.util.List;
11-
import java.util.stream.IntStream;
1216

1317
/**
1418
* A class containing methods to find interfaces in a given structure.
@@ -37,11 +41,10 @@ public InterfaceFinder(Structure structure) {
3741
* Remove polymer chains with 0 atoms.
3842
*/
3943
private void trimPolyChains() {
40-
Iterator<Chain> it = polyChains.iterator();
41-
while (it.hasNext()) {
42-
int count = it.next().getAtomGroups().stream().flatMapToInt(g-> IntStream.of(g.getAtoms().size())).sum();
43-
if (count==0) it.remove();
44-
}
44+
polyChains.removeIf(chain -> {
45+
int count = chain.getAtomGroups().stream().map(Group::getAtoms).mapToInt(Collection::size).sum();
46+
return count == 0;
47+
});
4548
}
4649

4750
/**

0 commit comments

Comments
 (0)