2727import org .biojava .nbio .structure .align .util .AtomCache ;
2828import org .biojava .nbio .structure .io .MMCIFFileReader ;
2929import org .biojava .nbio .structure .io .PDBFileReader ;
30- import org .biojava .nbio .structure .quaternary .BiologicalAssemblyBuilder ;
31- import org .biojava .nbio .structure .quaternary .BiologicalAssemblyTransformation ;
32- import org .biojava .nbio .structure .quaternary .io .BioUnitDataProvider ;
33- import org .biojava .nbio .structure .quaternary .io .BioUnitDataProviderFactory ;
34- import org .slf4j .Logger ;
35- import org .slf4j .LoggerFactory ;
30+ //import org.slf4j.Logger;
31+ //import org.slf4j.LoggerFactory;
3632
3733/**
3834 * A class that provides static access methods for easy lookup of protein structure related components
4339 */
4440public class StructureIO {
4541
46- private static final Logger logger = LoggerFactory .getLogger (StructureIO .class );
42+ // private static final Logger logger = LoggerFactory.getLogger(StructureIO.class);
4743
4844 private static AtomCache cache ;
4945
5046
51- /** Loads a structure based on a name. Supported naming conventions are:
47+ /**
48+ * Loads a structure based on a name. Supported naming conventions are:
5249 *
53- * * <pre>
50+ * <pre>
5451 Formal specification for how to specify the <i>name</i>:
5552
5653 name := pdbID
@@ -81,7 +78,7 @@ public class StructureIO {
8178 BIOL:1fah:1 #biological assembly nr 1 for 1fah
8279 BIOL:1fah:2 #biological assembly nr 2 for 1fah
8380
84- </pre>
81+ * </pre>
8582 *
8683 * With the additional set of rules:
8784 *
@@ -121,8 +118,12 @@ public static void setAtomCache(AtomCache c){
121118 }
122119
123120 /**
124- * Returns the first biologicalAssembly that is available for a protein structure. For more documentation on quaternary structures see:
125- * {@link http://www.pdb.org/pdb/101/static101.do?p=education_discussion/Looking-at-Structures/bioassembly_tutorial.html}
121+ * Returns the first biological assembly that is available for the given PDB id.
122+ * If the assembly occurs through crystallographic symmetry, the symmetry partners
123+ * are added as new models.
124+ * <p>
125+ * For more documentation on quaternary structures see:
126+ * {@link http://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/biological-assemblies}
126127 *
127128 *
128129 * @param pdbId
@@ -132,95 +133,61 @@ public static void setAtomCache(AtomCache c){
132133 */
133134 public static Structure getBiologicalAssembly (String pdbId ) throws IOException , StructureException {
134135
135- return getBiologicalAssembly (pdbId ,1 );
136+ checkInitAtomCache ();
137+
138+ pdbId = pdbId .toLowerCase ();
139+
140+ Structure s = cache .getBiologicalAssembly (pdbId );
141+
142+ return s ;
136143 }
137144
138145 /**
139- * By default the getStructure method loads asym units. This access method allows to recreate the quaternary structure for a protein if it is available.
140- *
146+ * Returns the biological assembly for the given PDB id and bioassembly identifier.
147+ * If the assembly occurs through crystallographic symmetry, the symmetry partners
148+ * are added as new models.
141149 * @param pdbId
142150 * @param biolAssemblyNr - the ith biological assembly that is available for a PDB ID (we start counting at 1, 0 represents the asym unit).
143151 * @return a Structure object or null if that assembly is not available
144152 * @throws StructureException if there is no bioassembly available for given biolAssemblyNr or some other problems encountered while loading it
145153 * @throws IOException
146154 */
147155 public static Structure getBiologicalAssembly (String pdbId , int biolAssemblyNr ) throws IOException , StructureException {
148- checkInitAtomCache ();
149- return getBiologicalAssembly (pdbId ,biolAssemblyNr ,StructureIO .cache );
150- }
151- public static Structure getBiologicalAssembly (String pdbId , int biolAssemblyNr , AtomCache cache ) throws StructureException {
152-
153- BioUnitDataProvider provider = null ;
154- try {
155- provider = BioUnitDataProviderFactory .getBioUnitDataProvider ();
156- provider .setAtomCache (cache );
157- Structure bio = getBiologicalAssembly (pdbId , biolAssemblyNr ,cache ,BioUnitDataProviderFactory .getBioUnitDataProvider ());
158- return bio ;
159- } finally {
160- if (provider != null ) {
161- //cleanup to avoid memory leaks
162- provider .setAsymUnit (null );
163- provider .setAtomCache (null );
164- }
165- }
166- }
167- public static Structure getBiologicalAssembly (String pdbId , int biolAssemblyNr , AtomCache cache , BioUnitDataProvider provider ) throws StructureException {
156+
157+ checkInitAtomCache ();
168158
169159 pdbId = pdbId .toLowerCase ();
170-
171-
172-
173- Structure asymUnit = provider .getAsymUnit (pdbId );
174-
175- // 0 ... asym unit
176- if ( biolAssemblyNr == 0 ) {
177- logger .info ("Requested biological assembly 0 for PDB id " +pdbId +", returning asymmetric unit" );
178- return asymUnit ;
179- }
180- // does it exist?
181- if (!asymUnit .getPDBHeader ().getBioAssemblies ().containsKey (biolAssemblyNr )) {
182- throw new StructureException ("No biological assembly available for biological assembly nr " + biolAssemblyNr + " of " + pdbId );
183- }
184-
185- List <BiologicalAssemblyTransformation > transformations =
186- asymUnit .getPDBHeader ().getBioAssemblies ().get (biolAssemblyNr ).getTransforms ();
187-
188-
189- if ( transformations == null || transformations .size () == 0 ){
190-
191- throw new StructureException ("Could not load transformations to recreate biological assembly nr " + biolAssemblyNr + " of " + pdbId );
192- }
193- BiologicalAssemblyBuilder builder = new BiologicalAssemblyBuilder ();
194-
195- return builder .rebuildQuaternaryStructure (asymUnit , transformations );
160+
161+ Structure s = cache .getBiologicalAssembly (pdbId , biolAssemblyNr );
162+
163+ return s ;
196164 }
197-
165+
198166 /**
199- * Does the provider PDB ID have a biological assembly?
200- *
167+ * Returns all biological assemblies for the given PDB id.
168+ * If the assembly occurs through crystallographic symmetry, the symmetry partners
169+ * are added as new models.
170+ * <p>
171+ * If only one biological assembly is required use {@link #getBiologicalAssembly(String)} or {@link #getBiologicalAssembly(String, int)} instead.
201172 * @param pdbId
202- * @return flag if one or more biological assemblies are available
173+ * @return
174+ * @throws IOException
175+ * @throws StructureException
176+ * @since 5.0
203177 */
204- public static boolean hasBiologicalAssembly (String pdbId ){
178+ public static List < Structure > getBiologicalAssemblies (String pdbId ) throws IOException , StructureException {
205179
206- pdbId = pdbId .toLowerCase ();
207-
208- BioUnitDataProvider provider = BioUnitDataProviderFactory .getBioUnitDataProvider ();
209- checkInitAtomCache ();
210- provider .setAtomCache (cache );
211- return provider .hasBiolAssembly (pdbId );
180+ checkInitAtomCache ();
212181
182+ pdbId = pdbId .toLowerCase ();
183+
184+ List <Structure > s = cache .getBiologicalAssemblies (pdbId );
185+
186+ return s ;
187+
213188 }
214189
215- public static int getNrBiologicalAssemblies (String pdbId ){
216-
217- pdbId = pdbId .toLowerCase ();
218-
219- BioUnitDataProvider provider = BioUnitDataProviderFactory .getBioUnitDataProvider ();
220- checkInitAtomCache ();
221- provider .setAtomCache (cache );
222- return provider .getNrBiolAssemblies (pdbId );
223- }
190+
224191
225192 private static final String FILE_SEPARATOR = System .getProperty ("file.separator" );
226193
0 commit comments