Search in sources :

Example 11 with Protein

use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.

the class ProteinParserTest method checkAgreement.

private void checkAgreement(String pdbId) {
    System.out.println("checking agreement between written and expected ATOM records for " + pdbId);
    Protein protein = ProteinParser.source(pdbId).parse();
    List<String> writtenLines = Pattern.compile("\n").splitAsStream(protein.getPdbRepresentation()).collect(Collectors.toList());
    try {
        List<String> expectedLines = Files.lines(Paths.get(TestUtils.getResourceAsFilepath("parser/parsed/" + pdbId + ".pdb"))).collect(Collectors.toList());
        for (int i = 0; i < writtenLines.size(); i++) {
            // some file have shorter lines
            if (expectedLines.get(i).length() > writtenLines.get(i).length()) {
                Assert.assertTrue("ATOM records do not match!" + System.lineSeparator() + "expected: " + expectedLines.get(i) + System.lineSeparator() + "actual:   " + writtenLines.get(i), expectedLines.get(i).startsWith(writtenLines.get(i)));
            } else {
                Assert.assertTrue("ATOM records do not match!" + System.lineSeparator() + "expected: " + expectedLines.get(i) + System.lineSeparator() + "actual:   " + writtenLines.get(i), writtenLines.get(i).startsWith(expectedLines.get(i)));
            }
        }
    } catch (IOException e) {
        throw new UncheckedIOException("did not find expected output file for " + pdbId, e);
    }
}
Also used : UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Protein(de.bioforscher.jstructure.model.structure.Protein)

Example 12 with Protein

use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.

the class SecondaryStructureAnnotatorTest method getDSSPAnnotatedStructure.

private String getDSSPAnnotatedStructure(String id) throws IOException, StructureException {
    // load structure
    Structure protein = new PDBFileReader().getStructureById(id);
    // assign states
    new SecStrucCalc().calculate(protein, true);
    // return complete DSSP annotation string from BioJava
    return protein.getChains().stream().flatMap(chain -> chain.getAtomGroups(GroupType.AMINOACID).stream()).map(aminoAcid -> aminoAcid.getProperty(Group.SEC_STRUC)).map(SecStrucState.class::cast).map(SecStrucState::getType).map(type -> String.valueOf(type.type)).collect(Collectors.joining());
}
Also used : PDBFileReader(org.biojava.nbio.structure.io.PDBFileReader) AbstractFeatureProvider(de.bioforscher.jstructure.model.feature.AbstractFeatureProvider) ProteinParser(de.bioforscher.jstructure.parser.ProteinParser) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) StructureException(org.biojava.nbio.structure.StructureException) SecStrucState(org.biojava.nbio.structure.secstruc.SecStrucState) Group(org.biojava.nbio.structure.Group) Structure(org.biojava.nbio.structure.Structure) SecStrucCalc(org.biojava.nbio.structure.secstruc.SecStrucCalc) Protein(de.bioforscher.jstructure.model.structure.Protein) Assert(org.junit.Assert) GroupType(org.biojava.nbio.structure.GroupType) PDBFileReader(org.biojava.nbio.structure.io.PDBFileReader) FeatureProviderRegistry(de.bioforscher.jstructure.model.feature.FeatureProviderRegistry) Before(org.junit.Before) SecStrucCalc(org.biojava.nbio.structure.secstruc.SecStrucCalc) SecStrucState(org.biojava.nbio.structure.secstruc.SecStrucState) Structure(org.biojava.nbio.structure.Structure)

Example 13 with Protein

use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.

the class ModelIntegrityTest method shouldGetProteinCopy.

@Test
public void shouldGetProteinCopy() {
    ChainContainer copiedProtein = protein.createCopy();
    Assert.assertTrue(copiedProtein instanceof Protein);
}
Also used : ChainContainer(de.bioforscher.jstructure.model.structure.container.ChainContainer) Protein(de.bioforscher.jstructure.model.structure.Protein) Test(org.junit.Test)

Example 14 with Protein

use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.

the class ProteinParserTest method shouldAnnotateHetAtmsCorrectlyFor1bs2.

@Test
public void shouldAnnotateHetAtmsCorrectlyFor1bs2() {
    /*
         * 1bs2 is an aars structure with the amino acid arginine in the binding site (annotated as ATOM record), some
         * water (annotated as HETATM)
         */
    Protein protein1bs2 = ProteinParser.source("1bs2").parse();
    List<Group> waters = protein1bs2.select().water().asFilteredGroups().collect(Collectors.toList());
    waters.forEach(group -> {
        Assert.assertTrue(group.isLigand());
        Assert.assertTrue("water records ought to start with HETATM", group.getPdbRepresentation().startsWith(Atom.HETATM_PREFIX));
    });
    Group arginineAsLigand = protein1bs2.select().residueNumber(900).asGroup();
    // assert that selection does not return ARG ligand as normal amino acid
    boolean arginineLigandIsNoAminoAcid = protein1bs2.aminoAcids().noneMatch(group -> group.equals(arginineAsLigand));
    Assert.assertTrue("amino acid ligand ought to be not a part of the amino acid chain", arginineLigandIsNoAminoAcid);
    // ensure last amino acid is MET and not the ARG ligand
    Assert.assertThat(protein1bs2.getAminoAcidSequence(), endsWith("M"));
    List<Group> hetatm1bs2 = protein1bs2.select().hetatms().asFilteredGroups().collect(Collectors.toList());
    Assert.assertTrue(hetatm1bs2.containsAll(waters) && hetatm1bs2.contains(arginineAsLigand));
}
Also used : Group(de.bioforscher.jstructure.model.structure.Group) Protein(de.bioforscher.jstructure.model.structure.Protein) Test(org.junit.Test)

Example 15 with Protein

use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.

the class ProteinParserTest method shouldHandleModifiedResidue.

@Test
public void shouldHandleModifiedResidue() {
    Protein protein = ProteinParser.source("1brr").parse();
    Group pca = protein.select().chainName("C").residueNumber(1).asGroup();
    Assert.assertTrue(pca.isAminoAcid());
    Assert.assertFalse(pca.isLigand());
    // assert correct mapping of PCA to GLU
    Assert.assertEquals("incorrect mapping of PCA to GLU", "E", pca.getGroupPrototype().getOneLetterCode().get());
}
Also used : Group(de.bioforscher.jstructure.model.structure.Group) Protein(de.bioforscher.jstructure.model.structure.Protein) Test(org.junit.Test)

Aggregations

Protein (de.bioforscher.jstructure.model.structure.Protein)32 Test (org.junit.Test)25 IOException (java.io.IOException)10 ProteinParser (de.bioforscher.jstructure.parser.ProteinParser)8 Collectors (java.util.stream.Collectors)8 Group (de.bioforscher.jstructure.model.structure.Group)7 List (java.util.List)6 AbstractFeatureProvider (de.bioforscher.jstructure.model.feature.AbstractFeatureProvider)5 FeatureProviderRegistry (de.bioforscher.jstructure.model.feature.FeatureProviderRegistry)5 Assert (org.junit.Assert)5 Before (org.junit.Before)4 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)3 UncheckedIOException (java.io.UncheckedIOException)3 Paths (java.nio.file.Paths)3 Stream (java.util.stream.Stream)3 LoopFraction (de.bioforscher.jstructure.feature.loopfraction.LoopFraction)2 Atom (de.bioforscher.jstructure.model.structure.Atom)2 Chain (de.bioforscher.jstructure.model.structure.Chain)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2