private void addSites ( ) { List < Site > sites = structure . getSites ( ) ; if ( sites == null ) sites = new ArrayList < Site > ( ) ; for ( StructSiteGen siteGen : structSiteGens ) { // For each StructSiteGen, find the residues involved, if they exist then String site_id = siteGen . getSite_id ( ) ; // multiple could be in same site. if ( site_id == null ) site_id = "" ; String comp_id = siteGen . getLabel_comp_id ( ) ; // PDBName // Assumption: the author chain ID and residue number for the site is consistent with the original // author chain id and residue numbers. String asymId = siteGen . getLabel_asym_id ( ) ; // chain name String authId = siteGen . getAuth_asym_id ( ) ; // chain Id String auth_seq_id = siteGen . getAuth_seq_id ( ) ; // Res num String insCode = siteGen . getPdbx_auth_ins_code ( ) ; if ( insCode != null && insCode . equals ( "?" ) ) insCode = null ; // Look for asymID = chainID and seqID = seq_ID. Check that comp_id matches the resname. Group g = null ; try { Chain chain = structure . getChain ( asymId ) ; if ( null != chain ) { try { Character insChar = null ; if ( null != insCode && insCode . length ( ) > 0 ) insChar = insCode . charAt ( 0 ) ; g = chain . getGroupByPDB ( new ResidueNumber ( null , Integer . parseInt ( auth_seq_id ) , insChar ) ) ; } catch ( NumberFormatException e ) { logger . warn ( "Could not lookup residue : " + authId + auth_seq_id ) ; } } } catch ( StructureException e ) { logger . warn ( "Problem finding residue in site entry " + siteGen . getSite_id ( ) + " - " + e . getMessage ( ) , e . getMessage ( ) ) ; } if ( g != null ) { // 2. find the site_id, if not existing, create anew. Site site = null ; for ( Site asite : sites ) { if ( site_id . equals ( asite . getSiteID ( ) ) ) site = asite ; } boolean addSite = false ; // 3. add this residue to the site. if ( site == null ) { addSite = true ; site = new Site ( ) ; site . setSiteID ( site_id ) ; } List < Group > groups = site . getGroups ( ) ; if ( groups == null ) groups = new ArrayList < Group > ( ) ; // Check the self-consistency of the residue reference from auth_seq_id and chain_id if ( ! comp_id . equals ( g . getPDBName ( ) ) ) { logger . warn ( "comp_id doesn't match the residue at " + authId + " " + auth_seq_id + " - skipping" ) ; } else { groups . add ( g ) ; site . setGroups ( groups ) ; } if ( addSite ) sites . add ( site ) ; } } structure . setSites ( sites ) ; }
Build sites in a BioJava Structure using the original author chain id & residue numbers . Sites are built from struct_site_gen records that have been parsed .