private void linkSitesToGroups ( ) { //System.out.println("LINK SITES TO GROUPS:" + siteToResidueMap.keySet().size()); //link the map of siteIds : <ResidueNumber> with the sites by using ResidueNumber to get the correct group back. //the return list if ( siteMap == null || siteToResidueMap == null ) { logger . info ( "Sites can not be linked to residues!" ) ; return ; } List < Site > sites = null ; //check that there are chains with which to associate the groups if ( structure . getChains ( ) . isEmpty ( ) ) { sites = new ArrayList < Site > ( siteMap . values ( ) ) ; logger . info ( "No chains to link Site Groups with - Sites will not be present in the Structure" ) ; return ; } //check that the keys in the siteMap and SiteToResidueMap are equal if ( ! siteMap . keySet ( ) . equals ( siteToResidueMap . keySet ( ) ) ) { logger . info ( "Not all sites have been properly described in the PDB " + pdbId + " header - some Sites will not be present in the Structure" ) ; logger . debug ( siteMap . keySet ( ) + " | " + siteToResidueMap . keySet ( ) ) ; //return; } //so we have chains - associate the siteResidues-related groups with the ones //already in in the chains for ( String key : siteMap . keySet ( ) ) { Site currentSite = siteMap . get ( key ) ; List < ResidueNumber > linkedGroups = siteToResidueMap . get ( key ) ; if ( linkedGroups == null ) continue ; for ( ResidueNumber residueNumber : linkedGroups ) { String pdbCode = residueNumber . toString ( ) ; String chain = residueNumber . getChainName ( ) ; // System.out.println("chain: '" + chain + "'"); // String resNum = resNum.getSeqNum().toString(); // System.out.println("resNum: '" + resNum + "'"); Group linkedGroup = null ; try { //TODO: implement findGroup(ResidueNumber resNum) linkedGroup = structure . findGroup ( chain , pdbCode ) ; } catch ( StructureException ex ) { logger . info ( "Can't find group " + pdbCode + " in chain " + chain + " in order to link up SITE records (PDB ID " + pdbId + ")" ) ; continue ; } // System.out.println("Adding group: " + linkedGroup.getSeqNum() + " to site " + site.getSiteID()); currentSite . getGroups ( ) . add ( linkedGroup ) ; } } //System.out.println("SITEMAP: " + siteMap); sites = new ArrayList < Site > ( siteMap . values ( ) ) ; structure . setSites ( sites ) ; //System.out.println("STRUCTURE SITES: " + structure.getSites().size()); // for (Site site : structure.getSites()) { // System.out.println(site); // } // System.out.println("Linked Site Groups with Chains"); }
Links the Sites in the siteMap to the Groups in the Structure via the siteToResidueMap ResidueNumber .