protected File downloadStructure ( String pdbId ) throws IOException { if ( pdbId . length ( ) != 4 ) throw new IOException ( "The provided ID does not look like a PDB ID : " + pdbId ) ; // decide whether download is required File existing = getLocalFile ( pdbId ) ; switch ( fetchBehavior ) { case LOCAL_ONLY : if ( existing == null ) { throw new IOException ( String . format ( "Structure %s not found in %s " + "and configured not to download." , pdbId , getPath ( ) ) ) ; } else { return existing ; } case FETCH_FILES : // Use existing if present if ( existing != null ) { return existing ; } // existing is null, downloadStructure(String,String,boolean,File) will download it break ; case FETCH_IF_OUTDATED : // here existing can be null or not: // existing == null : downloadStructure(String,String,boolean,File) will download it // existing != null : downloadStructure(String,String,boolean,File) will check its date and download if older break ; case FETCH_REMEDIATED : // Use existing if present and recent enough if ( existing != null ) { long lastModified = existing . lastModified ( ) ; if ( lastModified < LAST_REMEDIATION_DATE ) { // the file is too old, replace with newer version logger . warn ( "Replacing file {} with latest remediated (remediation of {}) file from PDB." , existing , LAST_REMEDIATION_DATE_STRING ) ; existing = null ; break ; } else { return existing ; } } case FORCE_DOWNLOAD : // discard the existing file to force redownload existing = null ; // downloadStructure(String,String,boolean,File) will download it break ; } // Force the download now if ( obsoleteBehavior == ObsoleteBehavior . FETCH_CURRENT ) { String current = PDBStatus . getCurrent ( pdbId ) ; if ( current == null ) { // either an error or there is not current entry current = pdbId ; } return downloadStructure ( current , splitDirURL , false , existing ) ; } else if ( obsoleteBehavior == ObsoleteBehavior . FETCH_OBSOLETE && PDBStatus . getStatus ( pdbId ) == Status . OBSOLETE ) { return downloadStructure ( pdbId , obsoleteDirURL , true , existing ) ; } else { return downloadStructure ( pdbId , splitDirURL , false , existing ) ; } }
Downloads an MMCIF file from the PDB to the local path