use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.
the class EnergyProfileCalculatorTest method shouldAgreeRegardingEnergyTerms.
@Test
public void shouldAgreeRegardingEnergyTerms() throws IOException {
Protein protein = ProteinParser.source("1bs2").parse();
featureProvider.process(protein);
Files.lines(Paths.get(TestUtils.getResourceAsFilepath("energy/1bs2.ep2"))).filter(line -> line.startsWith("ENGY")).map(line -> line.split("\t")).forEach(split -> {
Group group = protein.select().chainName(split[1]).residueNumber(Integer.valueOf(split[2])).asGroup();
Assert.assertEquals("energy values differ for " + group, Double.valueOf(split[5]), group.getFeatureContainer().getFeature(EnergyProfile.class).getSolvationEnergy(), 0.001);
});
}
use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.
the class OrientationsOfProteinsInMembranesAnnotator method processInternally.
@Override
protected void processInternally(Protein protein) {
try {
Document document = getDocument(SEARCH_URL + protein.getPdbId().getPdbId());
if (document.text().contains("No matches")) {
throw new ComputationException("did not find OPM entry for " + protein.getIdentifier() + " - possibly it is no membrane protein");
}
// create global membrane object - 3rd link points to download
String downloadLink = document.getElementById("caption").getElementsByTag("a").get(2).attr("href");
try (InputStreamReader inputStreamReader = new InputStreamReader(new URL(BASE_URL + downloadLink).openStream())) {
try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
byte[] bytes = bufferedReader.lines().collect(Collectors.joining(System.lineSeparator())).getBytes();
// parse protein
Protein opmProtein = ProteinParser.source(new ByteArrayInputStream(bytes)).forceProteinName(ProteinIdentifier.createFromPdbId(downloadLink.split("=")[0].split("/")[1].substring(0, 4))).parse();
Membrane membrane = new Membrane(this);
// superimpose opm protein onto instance of the original protein
//TODO this alignment is by no means perfect, but works for a first glance
SVDSuperimposer.ALPHA_CARBON_SVD_INSTANCE.align(protein.select().aminoAcids().asGroupContainer(), opmProtein.select().aminoAcids().asGroupContainer()).transform(opmProtein);
// extract dummy atoms and move them to membrane object
List<double[]> membraneAtoms = opmProtein.atoms().map(Atom::getParentGroup).filter(group -> group.getThreeLetterCode().equals("DUM")).flatMap(Group::atoms).map(Atom::getCoordinates).collect(Collectors.toList());
membrane.setMembraneAtoms(membraneAtoms);
// extract general information - that is the first table
Element generalDataTable = document.getElementsByClass("data").get(0);
Element thicknessTr = generalDataTable.getElementsByTag("tr").get(1);
membrane.setHydrophobicThickness(thicknessTr.getElementsByTag("td").get(1).text());
Element tiltTr = generalDataTable.getElementsByTag("tr").get(2);
membrane.setTiltAngle(tiltTr.getElementsByTag("td").get(1).text());
Element transferTr = generalDataTable.getElementsByTag("tr").get(3);
membrane.setDeltaGTransfer(transferTr.getElementsByTag("td").get(1).text());
Element topologyTr = generalDataTable.getElementsByTag("tr").get(5);
membrane.setTopology(topologyTr.getElementsByTag("td").get(1).text());
// extract trans-membrane helices - second table
Element transMembraneSubunitsTable = document.getElementsByClass("data").get(1);
List<TransMembraneHelix> helices = transMembraneSubunitsTable.getElementsByTag("tr").stream().skip(1).map(element -> element.getElementsByTag("td").get(0)).map(Element::text).map(TransMembraneHelix::new).collect(Collectors.toList());
membrane.setTransMembraneHelices(helices);
protein.getFeatureContainer().addFeature(membrane);
// //TODO remove, used to evaluate alignment manually
// Files.write(Paths.get(System.getProperty("user.home") + "/ori.pdb"), protein.getPdbRepresentation().getBytes());
// Files.write(Paths.get(System.getProperty("user.home") + "/opm.pdb"), opmProtein.getPdbRepresentation().getBytes());
// //TODO remove, used to evaluate segment positions manually
// Files.write(Paths.get(System.getProperty("user.home") + "/tm.pdb"), protein.select()
// .residueNumber(helices.stream()
// .map(TransMembraneHelix::getSegments)
// .flatMap(Collection::stream)
// .collect(Collectors.toList())
// .toArray(new IntegerRange[0]))
// .asGroupContainer()
// .getPdbRepresentation()
// .getBytes());
}
}
} catch (IOException e) {
throw new ComputationException("failed to fetch OPM file", e);
}
}
use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.
the class Demo method demo.
@Test
public void demo() {
// fetch protein from the PDB
Protein protein = ProteinParser.source("1brr").parse();
// compute the fraction of alanine in the protein
double alanineRatio = protein.select().groupName(Alanine.THREE_LETTER_CODE).asFilteredGroups().count() / (double) protein.getSize() * 100.0;
System.out.printf("alanine ratio: %3.2f%%", alanineRatio);
// compute some features - e.g. compute the loop fraction
FeatureProviderRegistry.resolve(LoopFraction.class).process(protein);
}
use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.
the class EnergyProfileCalculatorTest method shouldProcessStructureWithSelenomethionine.
@Test
public void shouldProcessStructureWithSelenomethionine() {
Protein protein = ProteinParser.source("3TQO").parse();
featureProvider.process(protein);
}
use of de.bioforscher.jstructure.model.structure.Protein in project jstructure by JonStargaryen.
the class PLIPAnnotatorTest method shouldAnnotateProteinWithWaterBridges.
@Test
public void shouldAnnotateProteinWithWaterBridges() {
Protein protein = ProteinParser.source("5A1S").parse();
plipAnnotator.process(protein);
}
Aggregations