Skip to content

Commit 892c03d

Browse files
committed
Merge remote-tracking branch 'upstream/master' into removeLoadChemCompInfo
2 parents 832f106 + b6b0525 commit 892c03d

File tree

8 files changed

+99
-47
lines changed

8 files changed

+99
-47
lines changed

biojava-alignment/src/main/java/org/biojava/nbio/alignment/SimpleGapPenalty.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,22 @@
2323

2424
package org.biojava.nbio.alignment;
2525

26+
import java.io.Serializable;
27+
2628
import org.biojava.nbio.alignment.template.GapPenalty;
2729

2830
/**
2931
* Implements a data structure for the gap penalties used during a sequence alignment routine.
3032
*
3133
* @author Mark Chapman
3234
*/
33-
public class SimpleGapPenalty implements GapPenalty {
35+
public class SimpleGapPenalty implements GapPenalty, Serializable {
3436

35-
private static int dgop = 10, dgep = 1;
37+
/**
38+
*
39+
*/
40+
private static final long serialVersionUID = 3945671344135815456L;
41+
private static int dgop = 10, dgep = 1;
3642

3743
/**
3844
* Sets the default gap extension penalty.

biojava-core/src/main/java/org/biojava/nbio/core/alignment/matrices/SimpleSubstitutionMatrix.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@
4141
* @author Paolo Pavan
4242
* @param <C> each element of the matrix corresponds to a pair of {@link Compound}s of type C
4343
*/
44-
public class SimpleSubstitutionMatrix<C extends Compound> implements SubstitutionMatrix<C> {
44+
public class SimpleSubstitutionMatrix<C extends Compound> implements SubstitutionMatrix<C>, Serializable {
45+
46+
/**
47+
*
48+
*/
49+
private static final long serialVersionUID = -2645265638108462479L;
4550

46-
private static final String comment = "#";
51+
private static final String comment = "#";
4752

4853
private CompoundSet<C> compoundSet;
4954
private String description, name;

biojava-core/src/main/java/org/biojava/nbio/core/alignment/matrices/SubstitutionMatrixHelper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
3131

3232
import java.io.InputStreamReader;
33+
import java.io.Serializable;
3334
import java.util.HashMap;
3435
import java.util.Map;
3536

@@ -40,9 +41,14 @@
4041
* @author Mark Chapman
4142
* @author Paolo Pavan
4243
*/
43-
public class SubstitutionMatrixHelper {
44+
public class SubstitutionMatrixHelper implements Serializable {
4445

45-
private static Map<String, SubstitutionMatrix<AminoAcidCompound>> aminoAcidMatrices =
46+
/**
47+
*
48+
*/
49+
private static final long serialVersionUID = 148491724604653225L;
50+
51+
private static Map<String, SubstitutionMatrix<AminoAcidCompound>> aminoAcidMatrices =
4652
new HashMap<String, SubstitutionMatrix<AminoAcidCompound>>();
4753
private static Map<String, SubstitutionMatrix<NucleotideCompound>> nucleotideMatrices =
4854
new HashMap<String, SubstitutionMatrix<NucleotideCompound>>();

biojava-core/src/main/java/org/biojava/nbio/core/sequence/compound/AminoAcidCompound.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
package org.biojava.nbio.core.sequence.compound;
2525

26+
import java.io.Serializable;
27+
2628
import org.biojava.nbio.core.sequence.template.AbstractCompound;
2729
import org.biojava.nbio.core.sequence.template.Compound;
2830
import org.biojava.nbio.core.sequence.template.CompoundSet;
@@ -33,9 +35,14 @@
3335
* @author Scooter Willis
3436
* @author Andy Yates
3537
*/
36-
public class AminoAcidCompound extends AbstractCompound {
38+
public class AminoAcidCompound extends AbstractCompound implements Serializable {
39+
40+
/**
41+
*
42+
*/
43+
private static final long serialVersionUID = -1955116496725902319L;
44+
private final AminoAcidCompoundSet compoundSet;
3745

38-
private final AminoAcidCompoundSet compoundSet;
3946

4047
public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName,
4148
String longName, String description, Float molecularWeight) {

biojava-core/src/main/java/org/biojava/nbio/core/sequence/compound/AminoAcidCompoundSet.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.biojava.nbio.core.sequence.template.CompoundSet;
2626
import org.biojava.nbio.core.sequence.template.Sequence;
2727

28+
import java.io.Serializable;
2829
import java.util.*;
2930

3031
/**
@@ -37,9 +38,13 @@
3738
* @author Scooter Willis
3839
* @author Mark Chapman
3940
*/
40-
public class AminoAcidCompoundSet implements CompoundSet<AminoAcidCompound> {
41+
public class AminoAcidCompoundSet implements CompoundSet<AminoAcidCompound>, Serializable {
4142

42-
private final Map<String, AminoAcidCompound> aminoAcidCompoundCache = new HashMap<String, AminoAcidCompound>();
43+
/**
44+
*
45+
*/
46+
private static final long serialVersionUID = 4000344194364133456L;
47+
private final Map<String, AminoAcidCompound> aminoAcidCompoundCache = new HashMap<String, AminoAcidCompound>();
4348
private final Map<String, AminoAcidCompound> aminoAcidCompoundCache3Letter = new HashMap<String, AminoAcidCompound>();
4449

4550
private final Map<AminoAcidCompound, Set<AminoAcidCompound>> equivalentsCache =

biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractCompound.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public abstract class AbstractCompound implements Compound {
3535
private String description = null;
3636
private Float molecularWeight = null;
3737

38+
39+
// Added an empty constructor for Serialization
40+
public AbstractCompound(){
41+
this.base = null;
42+
this.upperedBase = null;
43+
}
44+
3845
public AbstractCompound(String base) {
3946
this.base = base;
4047
this.upperedBase = base.toUpperCase();

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

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
*
5252
*/
5353
public class BondMaker {
54-
55-
54+
55+
5656
private static final Logger logger = LoggerFactory.getLogger(BondMaker.class);
57-
57+
5858
/**
5959
* The types of bonds that are read from struct_conn (type specified in field conn_type_id)
6060
*/
@@ -68,8 +68,8 @@ public class BondMaker {
6868
BOND_TYPES_TO_PARSE.add("covale_sugar");
6969
BOND_TYPES_TO_PARSE.add("modres");
7070
}
71-
72-
71+
72+
7373
/**
7474
* Maximum peptide (C - N) bond length considered for bond formation
7575
*/
@@ -249,7 +249,7 @@ public void formDisulfideBonds(List<SSBondImpl> disulfideBonds) {
249249
}
250250
structure.setSSBonds(bonds);
251251
}
252-
252+
253253
private Bond formDisulfideBond(SSBondImpl disulfideBond) {
254254
try {
255255
Atom a = getAtomFromRecord("SG", "", "CYS",
@@ -258,25 +258,25 @@ private Bond formDisulfideBond(SSBondImpl disulfideBond) {
258258
Atom b = getAtomFromRecord("SG", "", "CYS",
259259
disulfideBond.getChainID2(), disulfideBond.getResnum2(),
260260
disulfideBond.getInsCode2());
261-
261+
262262
Bond ssbond = new BondImpl(a, b, 1);
263-
263+
264264
structure.addSSBond(ssbond);
265-
265+
266266
return ssbond;
267-
267+
268268
} catch (StructureException e) {
269269
// Note, in Calpha only mode the CYS SG's are not present.
270270
if (! params.isParseCAOnly()) {
271271
logger.warn("Could not find atoms specified in SSBOND record: {}",disulfideBond.toString());
272272
} else {
273273
logger.debug("Could not find atoms specified in SSBOND record while parsing in parseCAonly mode.");
274274
}
275-
275+
276276
return null;
277277
}
278278
}
279-
279+
280280
/**
281281
* Creates bond objects from a LinkRecord as parsed from a PDB file
282282
* @param linkRecord
@@ -308,28 +308,34 @@ public void formLinkRecordBond(LinkRecord linkRecord) {
308308
} else {
309309
logger.debug("Could not find atoms specified in LINK record while parsing in parseCAonly mode.");
310310
}
311-
311+
312312
}
313313
}
314-
314+
315315
public void formBondsFromStructConn(List<StructConn> structConn) {
316-
316+
317317
final String symop = "1_555"; // For now - accept bonds within origin asymmetric unit.
318-
318+
319319
List<Bond> ssbonds = new ArrayList<>();
320-
320+
321321
for (StructConn conn : structConn) {
322-
322+
323323
if (!BOND_TYPES_TO_PARSE.contains(conn.getConn_type_id())) continue;
324-
325-
String chainId1 = conn.getPtnr1_auth_asym_id();
326-
String chainId2 = conn.getPtnr2_auth_asym_id();
327-
324+
String chainId1;
325+
String chainId2;
326+
if(params.isUseInternalChainId()){
327+
chainId1 = conn.getPtnr1_label_asym_id();
328+
chainId2 = conn.getPtnr2_label_asym_id();
329+
}
330+
else{
331+
chainId1 = conn.getPtnr1_auth_asym_id();
332+
chainId2 = conn.getPtnr2_auth_asym_id();
333+
}
328334
String insCode1 = "";
329335
if (!conn.getPdbx_ptnr1_PDB_ins_code().equals("?")) insCode1 = conn.getPdbx_ptnr1_PDB_ins_code();
330336
String insCode2 = "";
331337
if (!conn.getPdbx_ptnr2_PDB_ins_code().equals("?")) insCode2 = conn.getPdbx_ptnr2_PDB_ins_code();
332-
338+
333339
String seqId1 = conn.getPtnr1_auth_seq_id();
334340
String seqId2 = conn.getPtnr2_auth_seq_id();
335341
String resName1 = conn.getPtnr1_label_comp_id();
@@ -340,13 +346,13 @@ public void formBondsFromStructConn(List<StructConn> structConn) {
340346
if (!conn.getPdbx_ptnr1_label_alt_id().equals("?")) altLoc1 = conn.getPdbx_ptnr1_label_alt_id();
341347
String altLoc2 = "";
342348
if (!conn.getPdbx_ptnr2_label_alt_id().equals("?")) altLoc2 = conn.getPdbx_ptnr2_label_alt_id();
343-
349+
344350
Atom a1 = null;
345351
Atom a2 = null;
346-
352+
347353
try {
348354
a1 = getAtomFromRecord(atomName1, altLoc1, resName1, chainId1, seqId1, insCode1);
349-
355+
350356
} catch (StructureException e) {
351357
String altLocStr1 = altLoc1.isEmpty()? "" : "(alt loc "+altLoc1+")";
352358
logger.warn("Could not find atom specified in struct_conn record: {}{}({}) in chain {}, atom {} {}", seqId1, insCode1, resName1, chainId1, atomName1, altLocStr1);
@@ -359,7 +365,7 @@ public void formBondsFromStructConn(List<StructConn> structConn) {
359365
logger.warn("Could not find atom specified in struct_conn record: {}{}({}) in chain {}, atom {} {}", seqId2, insCode2, resName2, chainId2, atomName2, altLocStr2);
360366
continue;
361367
}
362-
368+
363369

364370
// TODO: when issue 220 is implemented, add robust symmetry handling to allow bonds between symmetry-related molecules.
365371
if (!conn.getPtnr1_symmetry().equals(symop) || !conn.getPtnr2_symmetry().equals(symop) ) {
@@ -374,32 +380,31 @@ public void formBondsFromStructConn(List<StructConn> structConn) {
374380
if (conn.getConn_type_id().equals("disulf")) {
375381
ssbonds.add(bond);
376382
}
377-
383+
378384
}
379-
385+
380386
// only for ss bonds we add a specific map in structure, all the rests are linked only from Atom.getBonds
381387
structure.setSSBonds(ssbonds);
382388
}
383-
389+
384390
private Atom getAtomFromRecord(String name, String altLoc, String resName, String chainID, String resSeq, String iCode)
385391
throws StructureException {
386-
392+
387393
if (iCode==null || iCode.isEmpty()) {
388394
iCode = " "; // an insertion code of ' ' is ignored
389395
}
390-
391396
Chain chain = structure.getChainByPDB(chainID);
392397
ResidueNumber resNum = new ResidueNumber(chainID, Integer.parseInt(resSeq), iCode.charAt(0));
393398
Group group = chain.getGroupByPDB(resNum);
394-
399+
395400
Group g = group;
396401
// there is an alternate location
397402
if (!altLoc.isEmpty()) {
398403
g = group.getAltLocGroup(altLoc.charAt(0));
399404
if (g==null)
400405
throw new StructureException("Could not find altLoc code "+altLoc+" in group "+resSeq+iCode+" of chain "+ chainID);
401406
}
402-
407+
403408
return g.getAtom(name);
404409
}
405410
}

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,13 @@ private void linkCompounds() {
929929

930930
for (int i =0; i< structure.nrModels() ; i++){
931931
for (Chain chain : structure.getModel(i)) {
932-
933-
String entityId = asymId2entityId.get(chain.getInternalChainID());
932+
String entityId;
933+
if( params.isUseInternalChainId()){
934+
entityId = asymId2entityId.get(chain.getChainID());
935+
}
936+
else{
937+
entityId = asymId2entityId.get(chain.getInternalChainID());
938+
}
934939
if (entityId==null) {
935940
// this can happen for instance if the cif file didn't have _struct_asym category at all
936941
// and thus we have no asymId2entityId mapping at all
@@ -1900,7 +1905,13 @@ private void addSites() {
19001905
String comp_id = siteGen.getLabel_comp_id(); // PDBName
19011906
// Assumption: the author chain ID and residue number for the site is consistent with the original
19021907
// author chain id and residue numbers.
1903-
String chain_id = siteGen.getAuth_asym_id(); // ChainID
1908+
String chain_id;
1909+
if (params.isUseInternalChainId()){
1910+
chain_id = siteGen.getLabel_asym_id();
1911+
}
1912+
else {
1913+
chain_id = siteGen.getAuth_asym_id(); // ChainID
1914+
}
19041915
String auth_seq_id = siteGen.getAuth_seq_id(); // Res num
19051916

19061917
String insCode = siteGen.getPdbx_auth_ins_code();

0 commit comments

Comments
 (0)