Search in sources :

Example 1 with AminoAcid

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

the class EnergyProfileCalculator method processInternally.

@Override
protected void processInternally(Protein protein) {
    final double squaredDistanceCutoff = DEFAULT_INTERACTION_CUTOFF * DEFAULT_INTERACTION_CUTOFF;
    final List<AminoAcid> aminoAcids = protein.aminoAcids().collect(Collectors.toList());
    for (AminoAcid currentGroup : aminoAcids) {
        Optional<Atom> currentGroupBetaCarbon = currentGroup.select().betaCarbonAtoms().asOptionalAtom();
        double[] currentGroupCoordinates = currentGroupBetaCarbon.map(Atom::getCoordinates).orElseGet(() -> currentGroup.calculate().centroid().getValue());
        double solvation = 0;
        double currentGroupSolvationValue = resolve(globularSolvationData, currentGroup);
        for (AminoAcid surroundingGroup : aminoAcids) {
            if (currentGroup.equals(surroundingGroup)) {
                continue;
            }
            Optional<Atom> surroundingGroupBetaCarbon = surroundingGroup.select().betaCarbonAtoms().asOptionalAtom();
            double[] surroundingGroupCoordinates = surroundingGroupBetaCarbon.map(Atom::getCoordinates).orElseGet(() -> surroundingGroup.calculate().centroid().getValue());
            if (LinearAlgebra.on(currentGroupCoordinates).distanceFast(surroundingGroupCoordinates) > squaredDistanceCutoff) {
                continue;
            }
            solvation += currentGroupSolvationValue + resolve(globularSolvationData, surroundingGroup);
        }
        currentGroup.getFeatureContainer().addFeature(new EnergyProfile(this, solvation));
    }
}
Also used : AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Atom(de.bioforscher.jstructure.model.structure.Atom)

Example 2 with AminoAcid

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

the class SequenceMotifAnnotator method processInternally.

@Override
protected void processInternally(Protein protein) {
    SequenceMotifContainer globalList = new SequenceMotifContainer(this);
    protein.chainsWithAminoAcids().forEach(chain -> {
        List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
        aminoAcids.forEach(group -> group.getFeatureContainer().addFeature(new SequenceMotifContainer(this)));
        int chainLength = aminoAcids.size();
        for (int resNum = 0; resNum < chainLength; resNum++) {
            AminoAcid startResidue = aminoAcids.get(resNum);
            char startAminoAcid = startResidue.getOneLetterCode().charAt(0);
            for (SequenceMotifDefinition candidate : SequenceMotifDefinition.values()) {
                int motifLength = Integer.parseInt(candidate.name().substring(2));
                char motifStart = candidate.name().charAt(0);
                char motifEnd = candidate.name().charAt(1);
                if (resNum + motifLength >= chainLength) {
                    continue;
                }
                if (startAminoAcid != motifStart) {
                    continue;
                }
                AminoAcid endResidue = aminoAcids.get(resNum + motifLength);
                if (endResidue.getOneLetterCode().charAt(0) != motifEnd) {
                    continue;
                }
                if (startResidue.getResidueNumber().getResidueNumber() + motifLength != endResidue.getResidueNumber().getResidueNumber()) {
                    continue;
                }
                List<AminoAcid> residueList = aminoAcids.subList(resNum, resNum + motifLength + 1);
                SequenceMotif sequenceMotif = new SequenceMotif(candidate, chain.getChainId().getChainId(), startResidue.getResidueNumber().getResidueNumber(), endResidue.getResidueNumber().getResidueNumber(), residueList.stream().map(AminoAcid::getOneLetterCode).collect(Collectors.joining()));
                if (!globalList.containsSequenceMotif(sequenceMotif)) {
                    globalList.addSequenceMotif(sequenceMotif);
                }
                logger.debug("found sequence motif: {}", sequenceMotif);
            }
        }
    });
    // set global reference to all entries
    protein.getFeatureContainer().addFeature(globalList);
}
Also used : AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)

Example 3 with AminoAcid

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

the class SecondaryStructureAnnotator method findBridges.

/**
     * Two nonoverlapping stretches of three residues each, i-1,i,i+1 and
     * j-1,j,j+1, form either a parallel or antiparallel bridge, depending on
     * which of two basic patterns is matched. We assign a bridge between
     * residues i and j if there are two H bonds characteristic of beta-
     * structure; in particular:
     * <p>
     * Parallel Bridge(i,j) =: [Hbond(i-1,j) and Hbond(j,i+1)]
     * 							or [Hbond(j-1,i) and Hbond(i,j+1)]
     * <p>
     * Antiparallel Bridge(i,j) =: [Hbond(i,j) and Hbond(j,i)]
     * 								or [Hbond(i-1,j+1) and Hbond(j-1,i+1)]
     *
     * Optimised to use the contact set
     */
private void findBridges(List<AminoAcid> residues, List<BetaBridge> bridges) {
    List<int[]> outList = new ArrayList<>();
    for (int i = 0; i < residues.size() - 1; i++) {
        for (int j = i + 1; j < residues.size(); j++) {
            AminoAcid res1 = residues.get(i);
            AminoAcid res2 = residues.get(j);
            try {
                double distance = LinearAlgebra.on(res1.getCa().getCoordinates()).distanceFast(res2.getCa().getCoordinates());
                if (distance > CA_MIN_DIST_SQUARED) {
                    continue;
                }
                // If i>j switch them over
                if (i > j) {
                    // Switch them over
                    int old = i;
                    i = j;
                    j = old;
                }
                // Only these
                if (j < i + 3) {
                    continue;
                }
                // If it's the first
                if (i == 0) {
                    continue;
                }
                if (j == 0) {
                    continue;
                }
                // If it's the last
                if (i == residues.size() - 1) {
                    continue;
                }
                if (j == residues.size() - 1) {
                    continue;
                }
                int[] thisPair = new int[] { i, j };
                outList.add(thisPair);
            } catch (NullPointerException e) {
                throw new SelectionException("missing alpha carbons for " + res1 + " or " + res2);
            }
        }
    }
    outList.sort((o1, o2) -> {
        if (o1[0] < o2[0]) {
            return -1;
        } else if (o1[0] > o2[0]) {
            return +1;
        } else {
            if (o1[1] < o2[1]) {
                return -1;
            } else if (o1[1] > o2[1]) {
                return +1;
            } else {
                return 0;
            }
        }
    });
    for (int[] p : outList) {
        int i = p[0];
        int j = p[1];
        BridgeType btype = null;
        // Now do the bonding
        if ((isBonded(residues, i - 1, j) && isBonded(residues, j, i + 1)) || (isBonded(residues, j - 1, i) && isBonded(residues, i, j + 1))) {
            btype = BridgeType.PARALLEL;
        } else if ((isBonded(residues, i, j) && isBonded(residues, j, i)) || (isBonded(residues, i - 1, j + 1) && (isBonded(residues, j - 1, i + 1)))) {
            btype = BridgeType.ANTIPARALLEL;
        }
        if (btype != null) {
            registerBridge(residues, bridges, i, j, btype);
        }
    }
}
Also used : AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) SelectionException(de.bioforscher.jstructure.model.structure.selection.SelectionException) ArrayList(java.util.ArrayList)

Example 4 with AminoAcid

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

the class SecondaryStructureAnnotator method calculateDihedralAngles.

private void calculateDihedralAngles(List<AminoAcid> residues) {
    // Omega: CA-C-N-CA
    for (int i = 0; i < residues.size() - 1; i++) {
        AminoAcid res1 = residues.get(i);
        AminoAcid res2 = residues.get(i + 1);
        TorsionAngles torsionAngles = new TorsionAngles(res1, res2);
        SecondaryStructure state1 = getState(res1);
        SecondaryStructure state2 = getState(res2);
        state2.setPhi(torsionAngles.getPhi());
        state1.setPsi(torsionAngles.getPsi());
        state1.setOmega(torsionAngles.getOmega());
    }
}
Also used : AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) TorsionAngles(de.bioforscher.jstructure.mathematics.TorsionAngles)

Example 5 with AminoAcid

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

the class BindingSiteExtractor method handleLine.

private void handleLine(String line, String className, String modeName) {
    System.out.println(line);
    // map to amino acid family
    String aminoAcid = Stream.of(AminoAcid.Family.values()).filter(aminoAcidFamily -> aminoAcidFamily.name().equalsIgnoreCase(line.split(":")[0])).findFirst().map(AminoAcid.Family::getGroupPrototype).map(GroupPrototype::getThreeLetterCode).orElse("Pyr");
    int[] residueNumbers = Pattern.compile(", ").splitAsStream(line.split("\\[")[1].split("]")[0]).mapToInt(Integer::valueOf).toArray();
    AARSConstants.lines(Paths.get(AARSConstants.MAIN_TABLE_CATALYTIC_PATH)).filter(mainTableLine -> mainTableLine.split(",")[1].equalsIgnoreCase(aminoAcid)).filter(mainTableLine -> mainTableLine.endsWith("1")).forEach(mainTableLine -> {
        String[] split = mainTableLine.split(",");
        String pdbId = split[2];
        String chainId = split[13];
        Protein protein = ProteinParser.source(AARSConstants.RENUMBERED_STRUCTURES_PATH + className + "/renumbered_structures/" + pdbId + "_renum.pdb").parse();
        String output = "HEADER    LIGASE/RNA                              15-JUL-99   " + pdbId.toUpperCase() + "              " + System.lineSeparator() + protein.select().chainName(chainId).aminoAcids().residueNumber(residueNumbers).asGroupContainer().getPdbRepresentation();
        AARSConstants.write(Paths.get(AARSConstants.BINDING_SITE_PATH + className + "/ligand_based/per_type/" + modeName + "/" + aminoAcid.substring(0, 1).toUpperCase() + aminoAcid.substring(1, 3).toLowerCase() + "/" + pdbId + "_" + chainId + "_renum.pdb"), output.getBytes());
    });
}
Also used : List(java.util.List) ProteinParser(de.bioforscher.jstructure.parser.ProteinParser) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) GroupPrototype(de.bioforscher.jstructure.model.structure.GroupPrototype) Pattern(java.util.regex.Pattern) Protein(de.bioforscher.jstructure.model.structure.Protein) Path(java.nio.file.Path) Collectors(java.util.stream.Collectors) Protein(de.bioforscher.jstructure.model.structure.Protein)

Aggregations

AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)66 Chain (de.bioforscher.jstructure.model.structure.Chain)40 Collectors (java.util.stream.Collectors)40 IOException (java.io.IOException)36 Files (java.nio.file.Files)35 List (java.util.List)31 StandardFormat (de.bioforscher.jstructure.StandardFormat)26 StructureParser (de.bioforscher.jstructure.model.structure.StructureParser)26 Path (java.nio.file.Path)25 Structure (de.bioforscher.jstructure.model.structure.Structure)23 Pattern (java.util.regex.Pattern)17 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 Start2FoldResidueAnnotation (de.bioforscher.jstructure.efr.model.Start2FoldResidueAnnotation)15 UncheckedIOException (java.io.UncheckedIOException)14 ArrayList (java.util.ArrayList)14 Stream (java.util.stream.Stream)14 Start2FoldResidueAnnotation (de.bioforscher.start2fold.model.Start2FoldResidueAnnotation)13 Optional (java.util.Optional)13 Pair (de.bioforscher.jstructure.mathematics.Pair)11