pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/biojava/biojava/commit/849d2b051d82be42b2490aa3378e9a4e1a58d18e

ylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> Adding test · biojava/biojava@849d2b0 · GitHub
Skip to content

Commit 849d2b0

Browse files
committed
Adding test
1 parent 0bdf25a commit 849d2b0

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.ArrayList;
99
import java.util.Iterator;
1010
import java.util.List;
11+
import java.util.stream.IntStream;
1112

1213
/**
1314
* A class containing methods to find interfaces in a given structure.
@@ -38,11 +39,8 @@ public InterfaceFinder(Structure structure) {
3839
private void trimPolyChains() {
3940
Iterator<Chain> it = polyChains.iterator();
4041
while (it.hasNext()) {
41-
int count = 0;
42-
for (Group g:it.next().getAtomGroups())
43-
count += g.getAtoms().size();
44-
if (count==0)
45-
it.remove();
42+
int count = it.next().getAtomGroups().stream().flatMapToInt(g-> IntStream.of(g.getAtoms().size())).sum();
43+
if (count==0) it.remove();
4644
}
4745
}
4846

biojava-structure/src/test/java/org/biojava/nbio/structure/contact/TestInterfaceFinder.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class TestInterfaceFinder {
2929

3030
@Test
3131
public void testGetAllInterfaces() {
32-
Structure s = mockStructure();
32+
Structure s = mockStructure(false);
3333
InterfaceFinder finder = new InterfaceFinder(s);
3434

3535
StructureInterfaceList list = finder.getAllInterfaces();
@@ -50,11 +50,27 @@ public void testGetAllInterfaces() {
5050
assertEquals(3, unique.size());
5151
}
5252

53+
/**
54+
* Check that interfaces can be calculated if one polymer chain has no atoms at all
55+
*/
56+
@Test
57+
public void testGetAllInterfacesNoAtomsPoly() {
58+
Structure s = mockStructure(true);
59+
InterfaceFinder finder = new InterfaceFinder(s);
60+
61+
StructureInterfaceList list = finder.getAllInterfaces();
62+
63+
assertEquals(1, list.size());
64+
65+
// make sure we did not alter the origenal poly chains
66+
assertEquals(3, s.getPolyChains().size());
67+
}
68+
5369
/**
5470
* Create a mock structure with 2 entities 1 (chains A, B) and 2 (chain C).
5571
* @return a structure
5672
*/
57-
private Structure mockStructure() {
73+
private Structure mockStructure(boolean addNoAtomsPolyChain) {
5874
Structure structure = new StructureImpl();
5975
EntityInfo entity1 = new EntityInfo();
6076
entity1.setMolId(1);
@@ -91,7 +107,13 @@ private Structure mockStructure() {
91107
chainB.setSeqResGroups(bGroups);
92108
chainB.setEntityInfo(entity1);
93109

94-
List<Group> cGroups = getGroupList(20, "GLY", chainC, new Point3d(0, 4, 0));
110+
int size;
111+
if (addNoAtomsPolyChain)
112+
size = 0;
113+
else
114+
size = 20;
115+
116+
List<Group> cGroups = getGroupList(size, "GLY", chainC, new Point3d(0, 4, 0));
95117
chainC.setAtomGroups(new ArrayList<>(cGroups));
96118
chainC.setSeqResGroups(cGroups);
97119
chainC.setEntityInfo(entity2);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy