@ Override public Structure loadStructure ( AtomCache cache ) throws StructureException , IOException { StructureFiletype format = StructureFiletype . UNKNOWN ; // Use user-specified format try { Map < String , String > params = parseQuery ( url ) ; if ( params . containsKey ( FORMAT_PARAM ) ) { String formatStr = params . get ( FORMAT_PARAM ) ; format = StructureIO . guessFiletype ( "." + formatStr ) ; } } catch ( UnsupportedEncodingException e ) { logger . error ( "Unable to decode URL " + url , e ) ; } // Guess format from extension if ( format == StructureFiletype . UNKNOWN ) { format = StructureIO . guessFiletype ( url . getPath ( ) ) ; } switch ( format ) { case CIF : // need to do mmcif parsing! InputStreamProvider prov = new InputStreamProvider ( ) ; InputStream inStream = prov . getInputStream ( url ) ; MMcifParser parser = new SimpleMMcifParser ( ) ; SimpleMMcifConsumer consumer = new SimpleMMcifConsumer ( ) ; consumer . setFileParsingParameters ( cache . getFileParsingParams ( ) ) ; parser . addMMcifConsumer ( consumer ) ; try { parser . parse ( new BufferedReader ( new InputStreamReader ( inStream ) ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } // now get the protein structure. return consumer . getStructure ( ) ; default : case PDB : // pdb file based parsing PDBFileReader reader = new PDBFileReader ( cache . getPath ( ) ) ; reader . setFetchBehavior ( cache . getFetchBehavior ( ) ) ; reader . setObsoleteBehavior ( cache . getObsoleteBehavior ( ) ) ; reader . setFileParsingParameters ( cache . getFileParsingParams ( ) ) ; return reader . getStructure ( url ) ; } }
Load the structure from the URL