use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.
the class A02_WriteDatasetCsv method handleProtein.
private static String handleProtein(String pdbId, String chainIds, String thermophile) {
System.out.println("handling " + thermophile + " protein " + pdbId + " with chains " + chainIds);
Structure structure = StructureParser.fromPdbId(pdbId).parse();
List<Chain> chains = chainIds.equals("Null") ? Stream.of(structure.chainsWithAminoAcids().findFirst().get()).collect(Collectors.toList()) : Pattern.compile(",").splitAsStream(chainIds).map(chainId -> {
Optional<Chain> optionalChain = structure.select().chainId(chainId).asOptionalChain();
return optionalChain.orElseGet(() -> structure.select().chainId(chainId.toUpperCase()).asChain());
}).collect(Collectors.toList());
return chains.stream().map(chain -> handleChain(pdbId, chain, thermophile)).collect(Collectors.joining(System.lineSeparator()));
}
Aggregations