public static Status [ ] getStatus ( String [ ] pdbIds ) { Status [ ] statuses = new Status [ pdbIds . length ] ; List < Map < String , String > > attrList = getStatusIdRecords ( pdbIds ) ; //Expect a single record if ( attrList == null || attrList . size ( ) != pdbIds . length ) { logger . error ( "Error getting Status for {} from the PDB website." , Arrays . toString ( pdbIds ) ) ; return null ; } for ( int pdbNum = 0 ; pdbNum < pdbIds . length ; pdbNum ++ ) { //Locate first element of attrList with matching structureId. //attrList is usually short, so don't worry about performance boolean foundAttr = false ; for ( Map < String , String > attrs : attrList ) { //Check that the record matches pdbId String id = attrs . get ( "structureId" ) ; if ( id == null || ! id . equalsIgnoreCase ( pdbIds [ pdbNum ] ) ) { continue ; } //Check that the status is given String statusStr = attrs . get ( "status" ) ; Status status = null ; if ( statusStr == null ) { logger . error ( "No status returned for {}" , pdbIds [ pdbNum ] ) ; statuses [ pdbNum ] = null ; } else { status = Status . fromString ( statusStr ) ; } if ( status == null ) { logger . error ( "Unknown status '{}'" , statusStr ) ; statuses [ pdbNum ] = null ; } statuses [ pdbNum ] = status ; foundAttr = true ; } if ( ! foundAttr ) { logger . error ( "No result found for {}" , pdbIds [ pdbNum ] ) ; statuses [ pdbNum ] = null ; } } return statuses ; }
Get the status of the a collection of PDBs in question in a single query .