public File getLocalFile ( String pdbId ) throws IOException { // Search for existing files // Search directories: // 1) LOCAL_MMCIF_SPLIT_DIR/<middle>/(pdb)?<pdbId>.<ext> // 2) LOCAL_MMCIF_ALL_DIR/<middle>/(pdb)?<pdbId>.<ext> LinkedList < File > searchdirs = new LinkedList < File > ( ) ; String middle = pdbId . substring ( 1 , 3 ) . toLowerCase ( ) ; File splitdir = new File ( splitDirPath , middle ) ; searchdirs . add ( splitdir ) ; // Search obsolete files if requested if ( getObsoleteBehavior ( ) == ObsoleteBehavior . FETCH_OBSOLETE ) { File obsdir = new File ( obsoleteDirPath , middle ) ; searchdirs . add ( obsdir ) ; } // valid prefixes before the <pdbId> in the filename String [ ] prefixes = new String [ ] { "" , "pdb" } ; for ( File searchdir : searchdirs ) { for ( String prefix : prefixes ) { for ( String ex : getExtensions ( ) ) { File f = new File ( searchdir , prefix + pdbId . toLowerCase ( ) + ex ) ; if ( f . exists ( ) ) { // delete files that are too short to have contents if ( f . length ( ) < MIN_PDB_FILE_SIZE ) { Files . delete ( f . toPath ( ) ) ; return null ; } return f ; } } } } //Not found return null ; }
Searches for previously downloaded files