File tree Expand file tree Collapse file tree
src/test/java/org/rcsb/cif/debugging Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Code & Tools for Debugging BinaryCIF
2+
3+ Debugging issues with BinaryCIF files is challenging. This package provides code snippets and tooling that come in handy
4+ when you need to investigate issues with a particular file. That file may or may not be written by another encoder.
5+
6+ ## How to Verify Encodings
7+
8+ BinaryCIF files are decoded lazily by the Java and JavaScript/TypeScript implementations. This means you can create a
9+ ` CifFile ` object but might run into issues when accessing compromised columns. Make sure to access all present
10+ categories and columns ensure that all data of a file is written properly.
11+
12+ Do that by looping over all categories and request all ` Column<?> ` instances for all categories.
13+ ` VerifyEncodingTest#whenReadingFile_thenAllColumnsAccessible ` demonstrates how to do that.
Original file line number Diff line number Diff line change 1+ package org .rcsb .cif .debugging ;
2+
3+ import org .junit .jupiter .api .Disabled ;
4+ import org .junit .jupiter .api .Test ;
5+ import org .rcsb .cif .CifIO ;
6+ import org .rcsb .cif .model .Category ;
7+ import org .rcsb .cif .schema .StandardSchemata ;
8+ import org .rcsb .cif .schema .mm .MmCifBlock ;
9+
10+ import java .io .IOException ;
11+ import java .nio .file .Path ;
12+ import java .nio .file .Paths ;
13+
14+ import static org .junit .jupiter .api .Assertions .fail ;
15+
16+ class VerifyEncodingTest {
17+ @ Test
18+ @ Disabled ("These tests are intended to be run manually on problematic files" )
19+ void whenReadingFile_thenAllColumnsAccessible () throws IOException {
20+ Path path = Paths .get ("/Users/sebastian/Downloads/py-bcif-converted/3j3q.bcif.gz" );
21+
22+ MmCifBlock block = CifIO .readFromPath (path ).as (StandardSchemata .MMCIF ).getFirstBlock ();
23+ for (Category category : block .getCategories ().values ()) {
24+ for (String columnName : category .getColumnNames ()) {
25+ String key = category .getCategoryName () + "." + columnName ;
26+
27+ try {
28+ // touching any property of this column triggers decoding and verifies that all data is accessible
29+ category .getColumn (columnName );
30+ } catch (ClassCastException e ) {
31+ fail ("Decoding of '" + key + "' failed as the observed encoding violates the BinaryCIF definition" , e );
32+ }
33+ }
34+ }
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments