use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class A04A_CreatePyMolRendering method handleChain.
private static void handleChain(ExplorerChain explorerChain) {
logger.info("handling chain {}", explorerChain.getStfId());
try {
Chain nativeChain = explorerChain.getChain();
Path nativeChainPath = Files.createTempFile("nativechain-", ".pdb");
Files.write(nativeChainPath, nativeChain.getPdbRepresentation().getBytes());
ReconstructionContactMap nativeContactMap = ReconstructionContactMap.createReconstructionContactMap(nativeChain, ContactDefinitionFactory.createAlphaCarbonContactDefinition(8.0));
List<AminoAcid> aminoAcids = nativeChain.getAminoAcids();
List<Pair<AminoAcid, AminoAcid>> contacts = nativeContactMap.getLongRangeContacts();
int numberNativeLongRangeContacts = contacts.size();
List<ReconstructionContactMap> reconstructionContactMaps = new ArrayList<>();
IntStream.of(5, 30, 100).forEach(coverage -> {
int numberOfContactsToSelect = (int) Math.round(0.01 * coverage * numberNativeLongRangeContacts);
for (int run = 0; run < REDUNDANCY; run++) {
Collections.shuffle(contacts);
List<Pair<AminoAcid, AminoAcid>> selectedContacts = contacts.subList(0, numberOfContactsToSelect);
ReconstructionContactMap contactMap = new ReconstructionContactMap(aminoAcids, selectedContacts, nativeContactMap.getContactDefinition());
contactMap.setName("p" + coverage + "-" + (run + 1));
reconstructionContactMaps.add(contactMap);
}
});
Map<String, List<Future<ReconstructionResult>>> reconstructionFutures = new HashMap<>();
for (ReconstructionContactMap contactMap : reconstructionContactMaps) {
String name = contactMap.getName().split("-")[0];
logger.info("handling contact map with coverage {}", name);
if (!reconstructionFutures.containsKey(name)) {
reconstructionFutures.put(name, new ArrayList<>());
}
List<Future<ReconstructionResult>> bin = reconstructionFutures.get(name);
bin.add(executorService.submit(new ConfoldServiceWorker("/home/sb/programs/confold_v1.0/confold.pl", contactMap.getSequence(), contactMap.getSecondaryStructureElements(), contactMap.getCaspRRRepresentation(), nativeContactMap.getConfoldRRType())));
}
for (Map.Entry<String, List<Future<ReconstructionResult>>> reconstructionFuture : reconstructionFutures.entrySet()) {
try {
String name = reconstructionFuture.getKey();
List<Chain> reconstructions = reconstructionFuture.getValue().stream().map(future -> {
try {
return future.get();
} catch (Exception e) {
throw new ComputationException(e);
}
}).map(ReconstructionResult::getChains).flatMap(Collection::stream).collect(Collectors.toList());
for (Chain reconstructedChain : reconstructions) {
Files.write(OUTPUT_PATH.resolve(name + ".pdb"), reconstructedChain.getPdbRepresentation().getBytes());
}
} catch (IOException e) {
throw new ComputationException(e);
}
}
} catch (IOException e) {
throw new ComputationException(e);
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class DictionaryOfProteinSecondaryStructure 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 (SelectionException e) {
logger.debug("missing alpha carbons for {} or {}", res1, 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);
}
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class DictionaryOfProteinSecondaryStructure method calculateHBonds.
/**
* Calculate the HBonds between different groups. see Creighton page 147 f
*/
private void calculateHBonds(List<AminoAcid> residues) {
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 squaredDistance = LinearAlgebra.on(res1.getCa().getCoordinates()).distanceFast(res2.getCa().getCoordinates());
if (squaredDistance > CA_MIN_DIST_SQUARED) {
continue;
}
checkAddHBond(res1, res2);
if (j != (i + 1)) {
checkAddHBond(res2, res1);
}
} catch (SelectionException e) {
logger.debug("missing alpha carbons for {} or {}", res1, res2);
}
}
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class EnergyProfileCalculator method processInternally.
@Override
protected void processInternally(Structure 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));
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class A01_CreatePyMolRenderJobsForEarlyFoldingResidues method composePyMolCommand.
private static String composePyMolCommand(String line) {
String[] split = line.split(";");
String entryId = 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.fromPdbId(pdbId).parse();
Chain chain = structure.chains().findFirst().get();
Start2FoldXmlParser.parseSpecificExperiment(chain, Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml"), experimentIds);
List<Integer> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).map(AminoAcid::getResidueIdentifier).map(ResidueIdentifier::getResidueNumber).collect(Collectors.toList());
return "delete all" + System.lineSeparator() + "fetch " + pdbId + ", async=0" + System.lineSeparator() + // hide non-relevant stuff
"hide everything" + System.lineSeparator() + "show cartoon, chain A" + System.lineSeparator() + // decolor everything
"color grey80" + System.lineSeparator() + "zoom (chain A)" + System.lineSeparator() + earlyFoldingResidues.stream().map(res -> "color efr, resi " + res).collect(Collectors.joining(System.lineSeparator())) + System.lineSeparator() + "ray" + System.lineSeparator() + "png " + Start2FoldConstants.PYMOL_DIRECTORY.resolve(entryId + "-efr.png") + System.lineSeparator();
}
Aggregations