-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced Usage
Francesco Palozzi edited this page Jun 5, 2026
·
1 revision
Useful when the input comes from a network connection, a ZIP entry, or any source that is not a plain file:
InputStream rawStream = mySource.openStream();
BufferedInputStream bis = new BufferedInputStream(rawStream);
RnaUnifier unifier = new RnaUnifier();
String result = unifier.process(bis, ToolType.FR3D, true);You can construct an ExtendedRNASecondaryStructure by hand without going through a parser — useful for testing or for integrating with other data sources:
ExtendedRNASecondaryStructure structure =
new ExtendedRNASecondaryStructure.Builder()
.setSequence("GCAUGC")
.addPair(new Pair(0, 5, "G", "C", BondType.LEONTIS_WESTHOF_cWW))
.addPair(new Pair(1, 4, "C", "G", BondType.LEONTIS_WESTHOF_cWW))
.addPair(new Pair(0, 3, "G", "U", BondType.LEONTIS_WESTHOF_tWH))
.addHeaderInfo("Source", "manual")
.build();
BpseqExporter exporter = new BpseqExporter();
System.out.println(exporter.printExtendedBPSEQ(structure));After parsing, you can iterate over all pairs and filter by type:
RnaStructureParser parser = ParserFactory.getParser(ToolType.RNAPOLIS);
ExtendedRNASecondaryStructure structure;
try (InputStream is = new FileInputStream("input.txt")) {
structure = parser.parse(is);
}
// All canonical pairs
structure.getCanonical().forEach(p ->
System.out.println((p.getPos1() + 1) + " → " + (p.getPos2() + 1))
);
// All cHS pairs
structure.getPairs().stream()
.filter(p -> p.getType() == BondType.LEONTIS_WESTHOF_cHS)
.forEach(System.out::println);If you need a different output format, extend BpseqExporter and inject your implementation:
public class MyExporter extends BpseqExporter {
@Override
public String printExtendedBPSEQ(ExtendedRNASecondaryStructure s) {
// your custom logic
}
}
RnaUnifier unifier = new RnaUnifier(new MyExporter());← Running Tests | Next: Troubleshooting →
RNA2DUnifier – Copyright © 2026 Francesco Palozzi.
University of Camerino – Licensed under the Apache License, Version 2.0.