Search in sources :

Example 1 with SecondaryStructureType

use of de.bioforscher.jstructure.feature.sse.SecondaryStructureType in project jstructure by JonStargaryen.

the class DictionaryOfProteinSecondaryStructure method updateSheets.

private void updateSheets(List<AminoAcid> residues, List<Ladder> ladders) {
    for (Ladder ladder : ladders) {
        for (int lcount = ladder.getFrom(); lcount <= ladder.getTo(); lcount++) {
            DSSPSecondaryStructure state = getState(residues.get(lcount));
            SecondaryStructureType stype = state.getSecondaryStructure();
            int diff = ladder.getFrom() - lcount;
            int l2count = ladder.getLfrom() - diff;
            DSSPSecondaryStructure state2 = getState(residues.get(l2count));
            SecondaryStructureType stype2 = state2.getSecondaryStructure();
            if (ladder.getFrom() != ladder.getTo()) {
                setSecStrucType(residues, lcount, SecondaryStructureType.EXTENDED);
                setSecStrucType(residues, l2count, SecondaryStructureType.EXTENDED);
            } else {
                if (!stype.isHelixType() && (!stype.equals(SecondaryStructureType.EXTENDED)))
                    setSecStrucType(residues, lcount, SecondaryStructureType.BRIDGE);
                if (!stype2.isHelixType() && (!stype2.equals(SecondaryStructureType.EXTENDED)))
                    setSecStrucType(residues, l2count, SecondaryStructureType.BRIDGE);
            }
        }
        if (ladder.getConnectedTo() == 0) {
            continue;
        }
        Ladder conladder = ladders.get(ladder.getConnectedTo());
        if (ladder.getBtype().equals(BridgeType.ANTIPARALLEL)) {
            /* set one side */
            for (int lcount = ladder.getFrom(); lcount <= conladder.getTo(); lcount++) {
                setSecStrucType(residues, lcount, SecondaryStructureType.EXTENDED);
            }
            /* set other side */
            for (int lcount = conladder.getLto(); lcount <= ladder.getLfrom(); lcount++) {
                setSecStrucType(residues, lcount, SecondaryStructureType.EXTENDED);
            }
        } else {
            /* set one side */
            for (int lcount = ladder.getFrom(); lcount <= conladder.getTo(); lcount++) {
                setSecStrucType(residues, lcount, SecondaryStructureType.EXTENDED);
            }
            /* set other side */
            for (int lcount = ladder.getLfrom(); lcount <= conladder.getLto(); lcount++) {
                setSecStrucType(residues, lcount, SecondaryStructureType.EXTENDED);
            }
        }
    }
}
Also used : SecondaryStructureType(de.bioforscher.jstructure.feature.sse.SecondaryStructureType)

Example 2 with SecondaryStructureType

use of de.bioforscher.jstructure.feature.sse.SecondaryStructureType in project jstructure by JonStargaryen.

the class DictionaryOfProteinSecondaryStructure method checkSetTurns.

private void checkSetTurns(List<AminoAcid> residues) {
    SecondaryStructureType type = SecondaryStructureType.TURN;
    for (int idx = 0; idx < 3; idx++) {
        for (int i = 0; i < residues.size() - 1; i++) {
            DSSPSecondaryStructure state = getState(residues.get(i));
            char[] turn = state.getTurn();
            // Any turn opening matters
            if (turn[idx] == '>' || turn[idx] == 'X') {
                // Mark following n residues as turn
                for (int k = 1; k < idx + 3; k++) {
                    setSecStrucType(residues, i + k, type);
                }
                if (!DSSP_HELICES) {
                    setSecStrucType(residues, i, type);
                    setSecStrucType(residues, i + idx + 3, type);
                }
            }
        }
    }
}
Also used : SecondaryStructureType(de.bioforscher.jstructure.feature.sse.SecondaryStructureType)

Example 3 with SecondaryStructureType

use of de.bioforscher.jstructure.feature.sse.SecondaryStructureType in project jstructure by JonStargaryen.

the class LoopFractionCalculatorTest method shouldComputeLoopFraction.

@Test
public void shouldComputeLoopFraction() {
    featureProvider.process(protein);
    protein.aminoAcids().forEach(group -> {
        SecondaryStructureType state = group.getFeature(DSSPSecondaryStructure.class).getSecondaryStructure();
        boolean isCoil = state.isCoilType();
        double value = group.getFeature(LoopFraction.class).getLoopFraction();
        System.out.println(group.getIdentifier() + "\t" + state.getOneLetterRepresentation() + "\t" + value);
        if (!isCoil) {
            Assert.assertTrue(value < 1.0);
        }
    });
}
Also used : DSSPSecondaryStructure(de.bioforscher.jstructure.feature.sse.dssp.DSSPSecondaryStructure) SecondaryStructureType(de.bioforscher.jstructure.feature.sse.SecondaryStructureType) Test(org.junit.Test)

Example 4 with SecondaryStructureType

use of de.bioforscher.jstructure.feature.sse.SecondaryStructureType in project jstructure by JonStargaryen.

the class A01_CreateContactMaps method handleFile.

private static void handleFile(String line) {
    String[] split = line.split(";");
    String stfId = split[0];
    String pdbId = split[1];
    List<Integer> experimentIds = Pattern.compile(",").splitAsStream(split[2].replaceAll("\\[", "").replaceAll("]", "")).map(Integer::valueOf).collect(Collectors.toList());
    Structure structure = StructureParser.fromPath(BASE_PATH.resolve("pdb").resolve(stfId + ".pdb")).parse();
    Chain chain = structure.chainsWithAminoAcids().findFirst().get();
    String sequence = chain.getAminoAcidSequence();
    String secondaryStructureString = chain.aminoAcids().map(aminoAcid -> aminoAcid.getFeature(GenericSecondaryStructure.class)).map(GenericSecondaryStructure::getSecondaryStructure).map(SecondaryStructureType::getReducedRepresentation).collect(Collectors.joining()).toUpperCase();
    Start2FoldConstants.write(BASE_PATH.resolve("reconstruction").resolve("fasta").resolve(stfId + ".fasta"), ">" + stfId + System.lineSeparator() + sequence);
    Start2FoldConstants.write(BASE_PATH.resolve("reconstruction").resolve("sse").resolve(stfId + ".sse"), ">" + stfId + System.lineSeparator() + secondaryStructureString);
    Start2FoldXmlParser.parseSpecificExperiment(chain, Start2FoldConstants.XML_DIRECTORY.resolve(stfId + ".xml"), experimentIds);
    List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
    List<AminoAcid> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).collect(Collectors.toList());
    List<Pair<AminoAcid, AminoAcid>> contacts = SetOperations.unorderedPairsOf(aminoAcids).filter(pair -> areNonCovalentGroups(pair.getLeft(), pair.getRight())).filter(pair -> ProteinGraphFactory.InteractionScheme.CALPHA8.areInContact(pair.getLeft(), pair.getRight())).collect(Collectors.toList());
    List<Pair<AminoAcid, AminoAcid>> earlyFoldingContacts = contacts.stream().filter(pair -> earlyFoldingResidues.contains(pair.getLeft()) && earlyFoldingResidues.contains(pair.getRight())).collect(Collectors.toList());
    String percentage = StandardFormat.formatToInteger(100 * earlyFoldingContacts.size() / (double) contacts.size());
    System.out.println("fraction of EFR contacts is " + percentage + "%: " + earlyFoldingContacts.size() + " " + contacts.size());
    Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-sampled-100-1.rr"), composeRRString(contacts, sequence));
    Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-efr-" + percentage + "-1.rr"), composeRRString(earlyFoldingContacts, sequence));
    for (int i = 5; i < 100; i = i + 5) {
        int numberOfContactsToSelect = (int) (i / (double) 100 * contacts.size());
        for (int j = 1; j < 6; j++) {
            Collections.shuffle(contacts);
            List<Pair<AminoAcid, AminoAcid>> selectedContacts = contacts.subList(0, numberOfContactsToSelect);
            Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-random-" + i + "-" + j + ".rr"), composeRRString(selectedContacts, sequence));
        }
    }
    // create samplings of random residues
    for (int i = 5; i < 100; i = i + 5) {
        int numberOfResiduesToSelect = (int) (i / (double) 100 * aminoAcids.size());
        for (int j = 1; j < 6; j++) {
            Collections.shuffle(aminoAcids);
            List<AminoAcid> selectedAminoAcids = aminoAcids.subList(0, numberOfResiduesToSelect);
            Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-residues-" + i + "-" + j + ".rr"), composeRRString(contacts.stream().filter(contact -> selectedAminoAcids.contains(contact.getLeft()) && selectedAminoAcids.contains(contact.getRight())).collect(Collectors.toList()), sequence));
        }
    }
    // create samplings of comparable nature of EFR contacts
    for (int j = 1; j < 6; j++) {
        int numberOfResiduesToSelect = earlyFoldingResidues.size();
        List<AminoAcid> interactingResidues = getInteractingResidues(aminoAcids, contacts, numberOfResiduesToSelect);
        Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-interacting-" + percentage + "-" + j + ".rr"), composeRRString(contacts.stream().filter(contact -> interactingResidues.contains(contact.getLeft()) && interactingResidues.contains(contact.getRight())).collect(Collectors.toList()), sequence));
    }
    // create bin samplings of comparable nature of EFR contacts
    for (int i = 5; i < 100; i = i + 5) {
        int numberOfResiduesToSelect = (int) (i / (double) 100 * aminoAcids.size());
        for (int j = 1; j < 6; j++) {
            List<AminoAcid> interactingResidues = getInteractingResidues(aminoAcids, contacts, numberOfResiduesToSelect);
            Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-interacting2-" + percentage + "-" + j + ".rr"), composeRRString(contacts.stream().filter(contact -> interactingResidues.contains(contact.getLeft()) && interactingResidues.contains(contact.getRight())).collect(Collectors.toList()), sequence));
        }
    }
}
Also used : Files(java.nio.file.Files) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) GenericSecondaryStructure(de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure) StructureParser(de.bioforscher.jstructure.model.structure.StructureParser) Collectors(java.util.stream.Collectors) Pair(de.bioforscher.jstructure.mathematics.Pair) ArrayList(java.util.ArrayList) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) List(java.util.List) Start2FoldConstants(de.bioforscher.start2fold.Start2FoldConstants) Paths(java.nio.file.Paths) SecondaryStructureType(de.bioforscher.jstructure.feature.sse.SecondaryStructureType) Group(de.bioforscher.jstructure.model.structure.Group) ProteinGraphFactory(de.bioforscher.jstructure.feature.graphs.ProteinGraphFactory) SetOperations(de.bioforscher.jstructure.mathematics.SetOperations) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Start2FoldXmlParser(de.bioforscher.start2fold.parser.Start2FoldXmlParser) Chain(de.bioforscher.jstructure.model.structure.Chain) Optional(java.util.Optional) StandardFormat(de.bioforscher.jstructure.StandardFormat) Pattern(java.util.regex.Pattern) Path(java.nio.file.Path) Collections(java.util.Collections) Chain(de.bioforscher.jstructure.model.structure.Chain) SecondaryStructureType(de.bioforscher.jstructure.feature.sse.SecondaryStructureType) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) GenericSecondaryStructure(de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure) Structure(de.bioforscher.jstructure.model.structure.Structure) GenericSecondaryStructure(de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure) Pair(de.bioforscher.jstructure.mathematics.Pair)

Aggregations

SecondaryStructureType (de.bioforscher.jstructure.feature.sse.SecondaryStructureType)4 StandardFormat (de.bioforscher.jstructure.StandardFormat)1 ProteinGraphFactory (de.bioforscher.jstructure.feature.graphs.ProteinGraphFactory)1 GenericSecondaryStructure (de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure)1 DSSPSecondaryStructure (de.bioforscher.jstructure.feature.sse.dssp.DSSPSecondaryStructure)1 Pair (de.bioforscher.jstructure.mathematics.Pair)1 SetOperations (de.bioforscher.jstructure.mathematics.SetOperations)1 Chain (de.bioforscher.jstructure.model.structure.Chain)1 Group (de.bioforscher.jstructure.model.structure.Group)1 Structure (de.bioforscher.jstructure.model.structure.Structure)1 StructureParser (de.bioforscher.jstructure.model.structure.StructureParser)1 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)1 Start2FoldConstants (de.bioforscher.start2fold.Start2FoldConstants)1 Start2FoldResidueAnnotation (de.bioforscher.start2fold.model.Start2FoldResidueAnnotation)1 Start2FoldXmlParser (de.bioforscher.start2fold.parser.Start2FoldXmlParser)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1