5454import org .biojava .nbio .structure .Author ;
5555import org .biojava .nbio .structure .Chain ;
5656import org .biojava .nbio .structure .ChainImpl ;
57- import org .biojava .nbio .structure .Compound ;
57+ import org .biojava .nbio .structure .EntityInfo ;
5858import org .biojava .nbio .structure .DBRef ;
5959import org .biojava .nbio .structure .Element ;
6060import org .biojava .nbio .structure .Group ;
@@ -179,8 +179,8 @@ public class PDBFileParser {
179179
180180 private boolean isLastCompndLine = false ;
181181 private boolean isLastSourceLine = false ;
182- private Compound current_compound ;
183- private List <Compound > compounds = new ArrayList <Compound >();
182+ private EntityInfo current_compound ;
183+ private List <EntityInfo > compounds = new ArrayList <EntityInfo >();
184184 private HashMap <Integer ,List <String >> compoundMolIds2chainIds = new HashMap <Integer , List <String >>();
185185 private List <String > compndLines = new ArrayList <String >();
186186 private List <String > sourceLines = new ArrayList <String >();
@@ -1012,7 +1012,7 @@ private void compndValueSetter(String field, String value) {
10121012
10131013 logger .debug ("Initialising new Compound with mol_id {}" , i );
10141014
1015- current_compound = new Compound ();
1015+ current_compound = new EntityInfo ();
10161016
10171017 current_compound .setMolId (i );
10181018
@@ -1027,7 +1027,7 @@ private void compndValueSetter(String field, String value) {
10271027 }
10281028
10291029 if (field .equals ("MOLECULE:" )) {
1030- current_compound .setMolName (value );
1030+ current_compound .setDescription (value );
10311031
10321032 }
10331033 if (field .equals ("CHAIN:" )) {
@@ -2758,11 +2758,37 @@ else if ( params.isParseSecStruc()) {
27582758 if ( params .isParseSecStruc () && !params .isHeaderOnly ())
27592759 setSecStruc ();
27602760
2761+ // Now correct the alternate location group
2762+ correctAltLocGroups ();
27612763
27622764 return structure ;
27632765
27642766 }
2767+
2768+
2769+ /**
2770+ * Ensure that all the alt loc groups have all the atoms in the main group
2771+ */
2772+ private void correctAltLocGroups () {
2773+ for (int i =0 ; i < structure .nrModels () ; i ++){
2774+ for (Chain chain : structure .getModel (i )) {
2775+ for (Group group : chain .getAtomGroups ()) {
2776+ for (Group altLocGroup : group .getAltLocs ()) {
2777+ for ( Atom groupAtom : group .getAtoms ()) {
2778+ // If this alt loc doesn't have this atom
2779+ if (! altLocGroup .hasAtom (groupAtom .getName ())) {
2780+ altLocGroup .addAtom (groupAtom );
2781+ }
2782+ }
2783+ }
2784+ }
2785+ }
2786+ }
2787+ }
27652788
2789+ /**
2790+ * Add the charges to the Structure
2791+ */
27662792 private void addCharges () {
27672793 ChargeAdder adder = new ChargeAdder (structure );
27682794 adder .addCharges ();
@@ -2789,7 +2815,7 @@ private void makeCompounds(List<String> compoundList,
27892815 // System.out.println("[makeCompounds] adding sources to compounds from sourceLines");
27902816 // since we're starting again from the first compound, reset it here
27912817 if ( compounds .size () == 0 ){
2792- current_compound = new Compound ();
2818+ current_compound = new EntityInfo ();
27932819 } else {
27942820 current_compound = compounds .get (0 );
27952821 }
@@ -2919,7 +2945,7 @@ private void triggerEndFileChecks(){
29192945
29202946 // to make sure we have Compounds linked to chains, we call getCompounds() which will lazily initialise the
29212947 // compounds using heuristics (see CompoundFinder) in the case that they were not explicitly present in the file
2922- structure .getCompounds ();
2948+ structure .getEntityInformation ();
29232949 }
29242950
29252951 private void setSecStruc (){
@@ -3002,15 +3028,15 @@ private void setSecElement(List<Map<String,String>> secList, String assignment,
30023028 }
30033029
30043030
3005- /** After the parsing of a PDB file the {@link Chain} and {@link Compound }
3031+ /** After the parsing of a PDB file the {@link Chain} and {@link EntityInfo }
30063032 * objects need to be linked to each other.
30073033 *
30083034 * @param s the structure
30093035 */
30103036 public void linkChains2Compound (Structure s ){
30113037
30123038
3013- for (Compound comp : compounds ){
3039+ for (EntityInfo comp : compounds ){
30143040 List <Chain > chains = new ArrayList <Chain >();
30153041 List <String > chainIds = compoundMolIds2chainIds .get (comp .getMolId ());
30163042 if ( chainIds == null )
@@ -3036,7 +3062,7 @@ public void linkChains2Compound(Structure s){
30363062 }
30373063
30383064 if ( compounds .size () == 1 ) {
3039- Compound comp = compounds .get (0 );
3065+ EntityInfo comp = compounds .get (0 );
30403066 if ( compoundMolIds2chainIds .get (comp .getMolId ()) == null ){
30413067 List <Chain > chains = s .getChains (0 );
30423068 if ( chains .size () == 1 ) {
@@ -3047,7 +3073,7 @@ public void linkChains2Compound(Structure s){
30473073 }
30483074 }
30493075
3050- for (Compound comp : compounds ){
3076+ for (EntityInfo comp : compounds ){
30513077 if ( compoundMolIds2chainIds .get (comp .getMolId ()) == null ) {
30523078 // could not link to chain
30533079 // TODO: should this be allowed to happen?
@@ -3073,7 +3099,7 @@ public void linkChains2Compound(Structure s){
30733099 for (Chain c : s .getChains ()) {
30743100 if (c .getCompound () == null ) {
30753101
3076- Compound compound = new Compound ();
3102+ EntityInfo compound = new EntityInfo ();
30773103 compound .addChain (c );
30783104 compound .setMolId (findMaxCompoundId (compounds )+1 );
30793105 c .setCompound (compound );
@@ -3085,13 +3111,13 @@ public void linkChains2Compound(Structure s){
30853111 }
30863112 }
30873113
3088- private static int findMaxCompoundId (List <Compound > compounds ) {
3114+ private static int findMaxCompoundId (List <EntityInfo > compounds ) {
30893115
30903116 return
30913117
3092- Collections .max (compounds , new Comparator <Compound >() {
3118+ Collections .max (compounds , new Comparator <EntityInfo >() {
30933119 @ Override
3094- public int compare (Compound o1 , Compound o2 ) {
3120+ public int compare (EntityInfo o1 , EntityInfo o2 ) {
30953121 return new Integer (o1 .getMolId ()).compareTo (o2 .getMolId ());
30963122 }
30973123 }).getMolId ();
0 commit comments