Search in sources :

Example 6 with GroupContainer

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));
}
Also used : AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) GroupContainer(de.bioforscher.jstructure.model.structure.container.GroupContainer) Test(org.junit.Test)

Example 7 with GroupContainer

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());
}
Also used : GroupContainer(de.bioforscher.jstructure.model.structure.container.GroupContainer) Test(org.junit.Test)

Example 8 with GroupContainer

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()));
}
Also used : Group(de.bioforscher.jstructure.model.structure.Group) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GroupContainer(de.bioforscher.jstructure.model.structure.container.GroupContainer) Pair(de.bioforscher.jstructure.model.Pair)

Example 9 with GroupContainer

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));
}
Also used : GroupContainer(de.bioforscher.jstructure.model.structure.container.GroupContainer) Test(org.junit.Test)

Aggregations

GroupContainer (de.bioforscher.jstructure.model.structure.container.GroupContainer)9 Test (org.junit.Test)7 Transformation (de.bioforscher.jstructure.mathematics.Transformation)1 Pair (de.bioforscher.jstructure.model.Pair)1 Chain (de.bioforscher.jstructure.model.structure.Chain)1 Group (de.bioforscher.jstructure.model.structure.Group)1 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)1 AtomContainer (de.bioforscher.jstructure.model.structure.container.AtomContainer)1 ChainContainer (de.bioforscher.jstructure.model.structure.container.ChainContainer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)1 LUDecomposition (org.apache.commons.math3.linear.LUDecomposition)1 RealMatrix (org.apache.commons.math3.linear.RealMatrix)1 SingularValueDecomposition (org.apache.commons.math3.linear.SingularValueDecomposition)1