Skip to content

Auto detection

Francesco Palozzi edited this page Jun 5, 2026 · 1 revision

Auto-Detection of Tool Type

When no ToolType is provided, RnaUnifier delegates to ParserFactory.detectTool(). This method peeks at the first 4 096 bytes of the stream and applies the following heuristics in priority order:

Priority Signal Detected tool
1 Contains BEGIN_base-pair RNAVIEW
2 Contains Residue conformations MCANNOTATE
3 Contains > and seq RNAPOLIS
4 JSON with key "annotations" FR3D
5 JSON with key "pairs" X3DNA
6 Lines matching N_INT_INT N_INT_INT XXc pattern BARNABA
7 Lines with ? separator and W:WC-style tokens BPNET

If no signature matches, an IllegalArgumentException is thrown.


Stream Requirements

The InputStream passed to detectTool (or to any auto-detecting process overload) must support mark()/reset(). A BufferedInputStream always satisfies this requirement.

If you are passing a raw FileInputStream, wrap it first:

try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(myFile))) {
    String result = unifier.process(bis, true);
}

Note: RnaUnifier.process(File, boolean) wraps the file internally, so you do not need to do this manually when passing a File object.


Output Formats | Next: Logging

Clone this wiki locally