use of de.bioforscher.jstructure.model.structure.container.GroupContainer in project jstructure by JonStargaryen.
the class SelectionTest method shouldSelectAminoAcidsAndReturnAsContainer.
@Test
public void shouldSelectAminoAcidsAndReturnAsContainer() {
List<Group> groups = protein.select().aminoAcids().asFilteredGroups().collect(Collectors.toList());
groups.forEach(group -> Assert.assertTrue("group " + group + " of original selected stream is no amino acid, was " + group.getClass().getSimpleName(), group instanceof AminoAcid));
GroupContainer container = groups.stream().collect(StructureCollectors.toIsolatedStructure());
container.groups().forEach(group -> Assert.assertTrue("group " + group + " of container stream is no amino acid, was " + group.getClass().getSimpleName(), group instanceof AminoAcid));
}
use of de.bioforscher.jstructure.model.structure.container.GroupContainer in project jstructure by JonStargaryen.
the class SelectionTest method shouldSelectGroupsFromChains.
@Test
public void shouldSelectGroupsFromChains() {
// select all arginines in chain 'B' and 'C'
System.out.println("arginines in Chain 'B' and 'C'");
GroupContainer argGroups = protein.select().chainName("B", "C").groupName(Arginine.THREE_LETTER_CODE).asIsolatedStructure();
System.out.println(argGroups.getPdbRepresentation());
// select hetatms in chain 'A'
System.out.println("Hetatms in Chain 'B':");
GroupContainer hets = protein.select().chainName("C").hetatms().asIsolatedStructure();
// assert that any atoms where selected
Assert.assertTrue(hets.getAtoms().size() > 0);
System.out.println(hets.getPdbRepresentation());
}
use of de.bioforscher.jstructure.model.structure.container.GroupContainer in project jstructure by JonStargaryen.
the class AbstractAlignmentAlgorithm method comparableGroupContainerPair.
/**
* Creates a comparable entity of 2 {@link AtomContainer} objects. They fulfill certain criteria:
* <ul>
* <li>{@link Atom}s are cloned
* <li>for each {@link Group} only shared atoms are retained</li>
* <li>{@link Atom}s are in identical ordering</li>
* <li>{@link Atom}s are wrapped in {@link Group} objects if they were initially</li>
* </ul>
* @param container1 a collection of reference atoms
* @param container2 a collection of candidate atoms
* @param minimalSetOfAtomNames the lower bound of required atom names present (e.g. by setting CA, every time an
* amino acid missing the alpha carbon will result in an exception thrown)
* @param maximalSetOfAtomNames the upper bound of required atom names present (e.g. by setting CA, everything else
* will be dropped, even when both amino acids would share more atoms)
* @return a pair of both collections which can now be aligned
*/
static Pair<GroupContainer, GroupContainer> comparableGroupContainerPair(AtomContainer container1, AtomContainer container2, Set<String> minimalSetOfAtomNames, Set<String> maximalSetOfAtomNames) {
//TODO what happens for alternative positions?
GroupContainer groupContainer1 = cloneIntoGroupContainer(container1);
GroupContainer groupContainer2 = cloneIntoGroupContainer(container2);
int limitingSize = Math.min(groupContainer1.getGroups().size(), groupContainer2.getGroups().size());
List<Group> groups1 = new ArrayList<>();
List<Group> groups2 = new ArrayList<>();
for (int groupIndex = 0; groupIndex < limitingSize; groupIndex++) {
Group group1 = groupContainer1.getGroups().get(groupIndex);
Group group2 = groupContainer2.getGroups().get(groupIndex);
Pair<List<Atom>, List<Atom>> sharedAtoms = selectSharedAtoms(group1, group2, minimalSetOfAtomNames, maximalSetOfAtomNames);
// remove additional/not-shared atoms
group1.getAtoms().clear();
group1.getAtoms().addAll(sharedAtoms.getLeft());
group2.getAtoms().clear();
group2.getAtoms().addAll(sharedAtoms.getRight());
logger.trace("shared atoms between {} and {}: {}", group1, group2, sharedAtoms);
groups1.add(group1);
groups2.add(group2);
}
return new Pair<>(groups1.stream().collect(StructureCollectors.toGroupContainer()), groups2.stream().collect(StructureCollectors.toGroupContainer()));
}
use of de.bioforscher.jstructure.model.structure.container.GroupContainer in project jstructure by JonStargaryen.
the class SelectionTest method shouldNameAfterParentContainer.
@Test
public void shouldNameAfterParentContainer() {
GroupContainer parentContainer = protein.select().cloneElements().nameContainer(givenName).asGroupContainer();
GroupContainer container = Selection.on(parentContainer).aminoAcids().asGroupContainer();
Assert.assertTrue(container.getIdentifier().equals(givenName));
}
Aggregations