Skip to content

Commit 748acc0

Browse files
committed
Removing the biounit providers package. Not all tests pass yet.
1 parent efec1cc commit 748acc0

21 files changed

Lines changed: 326 additions & 1574 deletions

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/StructureIOTest.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,29 @@
2020
*/
2121
package org.biojava.nbio.structure.test.io;
2222

23-
import junit.framework.TestCase;
23+
24+
import static org.junit.Assert.*;
25+
26+
import java.io.IOException;
27+
28+
import org.biojava.nbio.structure.StructureException;
2429
import org.biojava.nbio.structure.StructureIO;
30+
import org.junit.Test;
31+
32+
2533

26-
public class StructureIOTest extends TestCase {
27-
public void testStructureIO(){
34+
public class StructureIOTest {
35+
36+
@Test
37+
public void testStructureIO() throws IOException, StructureException {
2838

2939
String pdbId = "1gav";
3040

31-
int nrAssembls = StructureIO.getNrBiologicalAssemblies(pdbId);
41+
int nrAssembls = StructureIO.getBiologicalAssemblies(pdbId).size();
3242
assertEquals(1,nrAssembls);
3343

3444
pdbId = "1hv4";
35-
nrAssembls = StructureIO.getNrBiologicalAssemblies(pdbId);
45+
nrAssembls = StructureIO.getBiologicalAssemblies(pdbId).size();
3646
assertEquals(2,nrAssembls);
3747

3848
}

biojava-structure/src/main/java/org/biojava/nbio/structure/Chain.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public interface Chain {
227227
* Sets the 'private' asymId of this chain (Chain id in PDB file ).
228228
* @param asymId a String specifying the name value
229229
* @see #getChainID()
230-
* @deprecated use setId(String asymId) instead
230+
* @deprecated use {@link #setId(String asymId)} instead
231231
*/
232232
@Deprecated
233233
void setChainID(String asymId);
@@ -249,7 +249,7 @@ public interface Chain {
249249
*
250250
* @return String or null
251251
* @since 3.0.5
252-
* @deprecated use getId() instead
252+
* @deprecated use {@link #getId()} instead
253253
*/
254254
String getInternalChainID();
255255

@@ -258,7 +258,7 @@ public interface Chain {
258258
*
259259
* @param internalChainID
260260
* @since 3.0.5
261-
* @deprecated use getId() instead
261+
* @deprecated use {@link #setId()} instead
262262
*/
263263
void setInternalChainID(String internalChainID);
264264

biojava-structure/src/main/java/org/biojava/nbio/structure/ChainImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,14 @@ public Object clone() {
164164
ChainImpl n = new ChainImpl();
165165
// copy chain data:
166166

167-
n.setChainID( getChainID());
167+
n.setId(getId());
168168
n.setName(getName());
169169
n.setSwissprotId ( getSwissprotId());
170170

171171
// NOTE the EntityInfo will be reset at the parent level (Structure) if cloning is happening from parent level
172172
// here we don't deep-copy it and just keep the same reference, in case the cloning is happening at the Chain level only
173173
n.setEntityInfo(this.entity);
174174

175-
n.setInternalChainID(asymId);
176175

177176
for (Group group : groups) {
178177
Group g = (Group) group.clone();

biojava-structure/src/main/java/org/biojava/nbio/structure/PDBHeader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ public void setJournalArticle(JournalArticle journalArticle) {
598598

599599
/**
600600
* Return the map of biological assemblies. The keys are the
601-
* biological assembly identifiers, usually numerical from "1" to "n", but can also be "PAU" and "XAU"
601+
* biological assembly identifiers (starting at 1). Non-numerical identifiers
602+
* such as PAU or XAU are not supported.
602603
* @return
603604
*/
604605
public Map<Integer,BioAssemblyInfo> getBioAssemblies() {

biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIO.java

Lines changed: 48 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@
2727
import org.biojava.nbio.structure.align.util.AtomCache;
2828
import org.biojava.nbio.structure.io.MMCIFFileReader;
2929
import 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
@@ -43,14 +39,15 @@
4339
*/
4440
public 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

Comments
 (0)