use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.
the class AccessibleSurfaceAreaCalculatorTest method getJStructureASA.
private static List<Double> getJStructureASA(String id) {
// load structure
Structure protein = StructureParser.fromPdbId(id).parse();
// assign states
new AccessibleSurfaceAreaCalculator().process(protein);
// return complete DSSP annotation string from jstructrue
return protein.aminoAcids().map(residue -> residue.getFeature(AccessibleSurfaceArea.class).getAccessibleSurfaceArea()).collect(Collectors.toList());
}
use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.
the class Demo method test.
@Test
public void test() {
// fetch a structure or load from local PDB if setup
Structure structure = StructureParser.fromPdbId("1brr").parse();
// select a chain
Chain chainB = structure.select().chainId("B").asChain();
// or a residue
AminoAcid aminoAcid1 = chainB.select().residueNumber(60).asAminoAcid();
// and another one
AminoAcid aminoAcid2 = chainB.select().residueNumber(100).asAminoAcid();
// compute their distance
System.out.println("distance of " + aminoAcid1 + " and " + aminoAcid2 + ": " + StandardFormat.format(aminoAcid1.calculate().centroid().distance(aminoAcid2.calculate().centroid())));
// access amino acid-specific atoms
chainB.select().aminoAcids().groupName("TRP").asFilteredGroups().map(Tryptophan.class::cast).map(tryptophan -> tryptophan + " CG position: " + Arrays.toString(tryptophan.getCg().getCoordinates())).forEach(System.out::println);
// compute features on-the-fly and resolve dependencies
// e.g. assign some random value to each amino acid
structure.aminoAcids().forEach(aminoAcid -> aminoAcid.getFeatureContainer().addFeature(new Feature(new Random().nextDouble())));
chainB.aminoAcids().map(aminoAcid -> aminoAcid + " random feature: " + StandardFormat.format(aminoAcid.getFeature(Feature.class).getValue())).forEach(System.out::println);
System.out.println("averages among chains:");
structure.chainsWithAminoAcids().map(chain -> chain.getChainIdentifier() + "'s average random feature: " + StandardFormat.format(chain.aminoAcids().map(aminoAcid -> aminoAcid.getFeature(Feature.class)).mapToDouble(Feature::getValue).average().getAsDouble())).forEach(System.out::println);
}
use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.
the class S01_CreateEarlyFoldingDatabase method main.
public static void main(String[] args) {
StringJoiner efoldmineScript = new StringJoiner(System.lineSeparator());
List<String> lines = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("nrpdb.list"))).lines().collect(Collectors.toList());
Structure lastStructure = null;
String lastPdbId = null;
for (String line : lines) {
String[] split = line.split("\t");
String pdbId = split[0];
String chainId = split[1];
String id = pdbId + "_" + chainId;
System.out.println(id);
try {
Structure structure;
if (pdbId.equals(lastPdbId)) {
structure = lastStructure;
} else {
structure = StructureParser.fromPdbId(pdbId).parse();
}
Chain chain = structure.select().chainId(chainId).asChain();
String sequence = chain.getAminoAcidSequence();
FileUtils.write(BASE_DIR.resolve("sequences").resolve(id + ".fasta"), ">" + id + System.lineSeparator() + sequence);
efoldmineScript.add("python2 EFoldMine.py pdb-motifs/sequences/" + id + ".fasta -o pdb-motifs/ef-predictions/" + id + ".out");
lastPdbId = pdbId;
lastStructure = structure;
} catch (Exception e) {
System.err.println("could not process: " + line);
e.printStackTrace();
}
}
FileUtils.write(BASE_DIR.getParent().resolve("efoldmine-pdb-motifs.sh"), efoldmineScript.toString());
}
use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.
the class S02_ExtractEarlyFoldingMotifs method main.
public static void main(String[] args) {
FileUtils.list(Paths.get("/home/bittrich/git/phd_sb_repo/data/aars/EFoldMine_code/pdb-motifs/ef-predictions/")).parallel().forEach(earlyFoldingPredictionPath -> {
String id = earlyFoldingPredictionPath.toFile().getName().split("\\.")[0];
System.out.println(id);
Path motifPath = earlyFoldingPredictionPath.getParent().getParent().resolve("motifs").resolve(id + ".pdb");
String[] split = id.split("_");
String pdbId = split[0];
String chainId = split[1];
try {
Structure structure = StructureParser.fromPdbId(pdbId).parse();
Chain chain = structure.select().chainId(chainId).asChain();
List<AminoAcid> aminoAcids = chain.getAminoAcids();
List<String> earlyFoldingPredictionLines = Files.readAllLines(earlyFoldingPredictionPath);
List<Double> earlyFoldingPredictions = earlyFoldingPredictionLines.stream().skip(1).filter(line -> !line.startsWith("*")).map(line -> line.split("\\s+")[1]).map(Double::valueOf).collect(Collectors.toList());
if (aminoAcids.size() != earlyFoldingPredictions.size()) {
System.err.println("erroneous data for " + id);
return;
}
StringJoiner output = new StringJoiner(System.lineSeparator());
output.add(structure.getHeader());
List<AminoAcid> earlyFoldingResidues = new ArrayList<>();
for (int i = 0; i < aminoAcids.size(); i++) {
if (earlyFoldingPredictions.get(i) > CUTOFF) {
continue;
}
// is predicted as early folding
earlyFoldingResidues.add(aminoAcids.get(i));
}
Structure earlyFoldingStructure = earlyFoldingResidues.stream().collect(StructureCollectors.toIsolatedStructure());
FileUtils.write(motifPath, earlyFoldingStructure.getPdbRepresentation());
} catch (IOException e) {
e.printStackTrace();
}
});
}
use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.
the class S03_CreateSaneNrPdbList method filterValidChains.
private static boolean filterValidChains(Path path) {
System.out.println("processing " + path);
Structure structure = StructureParser.fromPath(path).parse();
return structure.getGroups().size() > 1;
}
Aggregations