Skip to content

Commit 00a4c9c

Browse files
committed
Merge branch 'master' of https://github.com/biojava/biojava.git
2 parents a3d594d + 58eb4e0 commit 00a4c9c

10 files changed

Lines changed: 155 additions & 130 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ public Object clone() {
175175
n.addAtom(atom);
176176
atom.setGroup(n);
177177
}
178+
179+
// copying the alt loc groups if present, otherwise they stay null
180+
if (getAltLocs()!=null && !getAltLocs().isEmpty()) {
181+
for (Group altLocGroup:this.getAltLocs()) {
182+
Group nAltLocGroup = (Group)altLocGroup.clone();
183+
n.addAltLoc(nAltLocGroup);
184+
}
185+
}
186+
178187
return n;
179188
}
180189

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

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import org.biojava.nbio.structure.io.FileConvert;
2828
import org.biojava.nbio.structure.io.PDBFileReader;
29-
import org.biojava.nbio.structure.io.SeqRes2AtomAligner;
3029
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
3130
import org.biojava.nbio.structure.io.mmcif.chem.PolymerType;
3231
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
@@ -171,33 +170,47 @@ public Object clone() {
171170
g.setChain(n);
172171
}
173172

174-
if (!seqResGroups.isEmpty()){
173+
174+
175+
if (seqResGroups!=null){
176+
177+
List<Group> tmpSeqRes = new ArrayList<Group>();
175178

176179
// cloning seqres and atom groups is ugly, due to their
177180
// nested relationship (some of the atoms can be in the seqres, but not all)
178-
179-
List<Group> tmpSeqRes = new ArrayList<Group>();
181+
180182
for (Group seqResGroup : seqResGroups) {
181-
Group g = (Group) seqResGroup.clone();
183+
184+
int i = findMathingGroupIndex(groups, seqResGroup);
185+
186+
Group g = null;
187+
188+
if (i!=-1) {
189+
// group found in atom groups, we get the equivalent reference from the newly cloned atom groups
190+
g = n.getAtomGroup(i);
191+
} else {
192+
// group not found in atom groups, we clone the seqres group
193+
g = (Group) seqResGroup.clone();
194+
}
182195
g.setChain(n);
183196
tmpSeqRes.add(g);
184197
}
185198

186-
Chain tmp = new ChainImpl();
187-
// that's a bit confusing, but that's how to set the seqres so that SeqRes2AtomAligner can use them
188-
tmp.setAtomGroups(tmpSeqRes);
189-
190-
// now match them up..
191-
SeqRes2AtomAligner seqresaligner = new SeqRes2AtomAligner();
192-
193-
seqresaligner.mapSeqresRecords(n, tmp);
194-
195-
199+
n.setSeqResGroups(tmpSeqRes);
196200
}
197-
201+
198202

199203
return n ;
200204
}
205+
206+
private static int findMathingGroupIndex(List<Group> atomGroups, Group g) {
207+
int i = 0;
208+
for (Group atomGroup: atomGroups) {
209+
if (g==atomGroup) return i;
210+
i++;
211+
}
212+
return -1;
213+
}
201214

202215

203216

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,13 @@ public Object clone() {
344344
atom.setGroup(n);
345345
}
346346

347-
// TODO alt locs are not cloned! do we need to clone them? - JD 2014-12-17
347+
// copying the alt loc groups if present, otherwise they stay null
348+
if (altLocs!=null) {
349+
for (Group altLocGroup:this.altLocs) {
350+
Group nAltLocGroup = (Group)altLocGroup.clone();
351+
n.addAltLoc(nAltLocGroup);
352+
}
353+
}
348354

349355
return n;
350356
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public Object clone(){
100100

101101
n.setPDBFlag(has3D());
102102
n.setResidueNumber(getResidueNumber());
103-
103+
104104
n.setPDBName(getPDBName());
105105

106106
// copy the atoms
@@ -109,6 +109,14 @@ public Object clone(){
109109
n.addAtom(atom);
110110
atom.setGroup(n);
111111
}
112+
113+
// copying the alt loc groups if present, otherwise they stay null
114+
if (getAltLocs()!=null && !getAltLocs().isEmpty()) {
115+
for (Group altLocGroup:this.getAltLocs()) {
116+
Group nAltLocGroup = (Group)altLocGroup.clone();
117+
n.addAltLoc(nAltLocGroup);
118+
}
119+
}
112120
return n;
113121
}
114122
}

biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ public class PDBFileParser {
108108

109109

110110

111-
// parsing options:
112-
113111
private static final Logger logger = LoggerFactory.getLogger(PDBFileParser.class);
112+
113+
// for printing
114+
private static final String NEWLINE = System.getProperty("line.separator");
115+
114116

115117
// required for parsing:
116118
private String pdbId; //the actual id of the entry
@@ -126,9 +128,7 @@ public class PDBFileParser {
126128
//(pdb_COMPOUND_handler for example)
127129
private boolean isLegacyFormat = false;
128130

129-
// for printing
130-
private static final String NEWLINE;
131-
131+
132132
// for re-creating the biological assembly
133133

134134
private PDBBioAssemblyParser bioAssemblyParser = null;
@@ -208,6 +208,8 @@ public class PDBFileParser {
208208

209209
private int atomCount;
210210

211+
// parsing options:
212+
211213
private int my_ATOM_CA_THRESHOLD ;
212214

213215
private int load_max_atoms;
@@ -217,11 +219,6 @@ public class PDBFileParser {
217219
/** flag to tell parser to only read Calpha coordinates **/
218220
private boolean parseCAonly;
219221

220-
static {
221-
222-
NEWLINE = System.getProperty("line.separator");
223-
224-
}
225222

226223
private FileParsingParameters params;
227224

@@ -257,23 +254,6 @@ public PDBFileParser() {
257254
linkRecords = new ArrayList<LinkRecord>();
258255
}
259256

260-
261-
262-
/**
263-
* Returns a time stamp.
264-
* @return a String representing the time stamp value
265-
*/
266-
protected String getTimeStamp(){
267-
268-
Calendar cal = Calendar.getInstance() ;
269-
// Get the components of the time
270-
int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23
271-
int min = cal.get(Calendar.MINUTE); // 0..59
272-
int sec = cal.get(Calendar.SECOND); // 0..59
273-
String s = "time: "+hour24+" "+min+" "+sec;
274-
return s ;
275-
}
276-
277257
/** initiate new resNum, either Hetatom, Nucleotide, or AminoAcid */
278258
private Group getNewGroup(String recordName,Character aminoCode1, String aminoCode3) {
279259

@@ -2576,16 +2556,13 @@ private BufferedReader getBufferedReader(InputStream inStream)
25762556
*/
25772557
public Structure parsePDBFile(InputStream inStream)
25782558
throws IOException
2579-
{
2559+
{
25802560

2581-
//System.out.println("preparing buffer");
25822561
BufferedReader buf = getBufferedReader(inStream);
25832562

2584-
//System.out.println("done");
2585-
25862563
return parsePDBFile(buf);
25872564

2588-
}
2565+
}
25892566

25902567
/**
25912568
* Parse a PDB file and return a datastructure implementing

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,27 +1229,30 @@ public void newDatabasePDBrev(DatabasePDBrev dbrev) {
12291229
if (dbrev.getNum().equals("1")){
12301230

12311231
try {
1232-
1233-
String date = dbrev.getDate_original();
1234-
//System.out.println(date);
1235-
Date dep = dateFormat.parse(date);
1236-
//System.out.println(dep);
1232+
Date dep = dateFormat.parse(dbrev.getDate_original());
12371233
header.setDepDate(dep);
1234+
1235+
} catch (ParseException e){
1236+
logger.warn("Could not parse date string '{}', deposition date will be unavailable", dbrev.getDate_original());
1237+
}
1238+
1239+
try {
12381240
Date mod = dateFormat.parse(dbrev.getDate());
1239-
12401241
header.setModDate(mod);
1241-
1242+
12421243
} catch (ParseException e){
1243-
e.printStackTrace();
1244+
logger.warn("Could not parse date string '{}', modification date will be unavailable", dbrev.getDate());
12441245
}
1246+
1247+
12451248
} else {
12461249
try {
12471250

12481251
Date mod = dateFormat.parse(dbrev.getDate());
12491252
header.setModDate(mod);
12501253

12511254
} catch (ParseException e){
1252-
e.printStackTrace();
1255+
logger.warn("Could not parse date string '{}', modification date will be unavailable", dbrev.getDate());
12531256
}
12541257
}
12551258

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/QuatSymmetryParameters.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
*/
2121
package org.biojava.nbio.structure.symmetry.core;
2222

23+
import java.io.Serializable;
2324
import java.util.Arrays;
2425

25-
public class QuatSymmetryParameters {
26+
public class QuatSymmetryParameters implements Serializable{
2627
private int minimumSequenceLength = 20;
2728
private int absoluteMinimumSequenceLength = 5;
2829
// if the shortest sequence length is >= 0.75 * the median sequence length,

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/BlastClustReader.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@
2424
import java.io.IOException;
2525
import java.io.InputStream;
2626
import java.io.InputStreamReader;
27+
import java.io.Serializable;
2728
import java.net.URL;
2829
import java.util.*;
2930

3031

31-
public class BlastClustReader {
32+
public class BlastClustReader implements Serializable {
3233
private int sequenceIdentity = 0;
3334
private List<List<String>> clusters = new ArrayList<List<String>>();
3435
private static final String coreUrl = "ftp://resources.rcsb.org/sequence/clusters/";
3536
private static List<Integer> seqIdentities = Arrays.asList(30, 40, 50, 70, 90, 95, 100);
3637

37-
public BlastClustReader(int sequenceIdentity) {
38+
public BlastClustReader(int sequenceIdentity) {
3839
this.sequenceIdentity = sequenceIdentity;
3940
}
4041

0 commit comments

Comments
 (0)