| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,16 +23,22 @@ | |||
| 23 | 23 | ||
| 24 | 24 | package org.biojava.nbio.alignment; | |
| 25 | 25 | ||
| 26 | + import java.io.Serializable; | ||
| 27 | + | ||
| 26 | 28 | import org.biojava.nbio.alignment.template.GapPenalty; | |
| 27 | 29 | ||
| 28 | 30 | /** | |
| 29 | 31 | * Implements a data structure for the gap penalties used during a sequence alignment routine. | |
| 30 | 32 | * | |
| 31 | 33 | * @author Mark Chapman | |
| 32 | 34 | */ | |
| 33 | - public class SimpleGapPenalty implements GapPenalty { | ||
| 35 | + public class SimpleGapPenalty implements GapPenalty, Serializable { | ||
| 34 | 36 | ||
| 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; | ||
| 36 | 42 | ||
| 37 | 43 | /** | |
| 38 | 44 | * Sets the default gap extension penalty. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,9 +41,14 @@ | |||
| 41 | 41 | * @author Paolo Pavan | |
| 42 | 42 | * @param <C> each element of the matrix corresponds to a pair of {@link Compound}s of type C | |
| 43 | 43 | */ | |
| 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; | ||
| 45 | 50 | ||
| 46 | - private static final String comment = "#"; | ||
| 51 | + private static final String comment = "#"; | ||
| 47 | 52 | ||
| 48 | 53 | private CompoundSet<C> compoundSet; | |
| 49 | 54 | private String description, name; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ | |||
| 30 | 30 | import org.biojava.nbio.core.sequence.compound.NucleotideCompound; | |
| 31 | 31 | ||
| 32 | 32 | import java.io.InputStreamReader; | |
| 33 | + import java.io.Serializable; | ||
| 33 | 34 | import java.util.HashMap; | |
| 34 | 35 | import java.util.Map; | |
| 35 | 36 | ||
@@ -40,9 +41,14 @@ | |||
| 40 | 41 | * @author Mark Chapman | |
| 41 | 42 | * @author Paolo Pavan | |
| 42 | 43 | */ | |
| 43 | - public class SubstitutionMatrixHelper { | ||
| 44 | + public class SubstitutionMatrixHelper implements Serializable { | ||
| 44 | 45 | ||
| 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 = | ||
| 46 | 52 | new HashMap<String, SubstitutionMatrix<AminoAcidCompound>>(); | |
| 47 | 53 | private static Map<String, SubstitutionMatrix<NucleotideCompound>> nucleotideMatrices = | |
| 48 | 54 | new HashMap<String, SubstitutionMatrix<NucleotideCompound>>(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,8 @@ | |||
| 23 | 23 | ||
| 24 | 24 | package org.biojava.nbio.core.sequence.compound; | |
| 25 | 25 | ||
| 26 | + import java.io.Serializable; | ||
| 27 | + | ||
| 26 | 28 | import org.biojava.nbio.core.sequence.template.AbstractCompound; | |
| 27 | 29 | import org.biojava.nbio.core.sequence.template.Compound; | |
| 28 | 30 | import org.biojava.nbio.core.sequence.template.CompoundSet; | |
@@ -33,9 +35,14 @@ | |||
| 33 | 35 | * @author Scooter Willis | |
| 34 | 36 | * @author Andy Yates | |
| 35 | 37 | */ | |
| 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; | ||
| 37 | 45 | ||
| 38 | - private final AminoAcidCompoundSet compoundSet; | ||
| 39 | 46 | ||
| 40 | 47 | public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName, | |
| 41 | 48 | String longName, String description, Float molecularWeight) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ | |||
| 25 | 25 | import org.biojava.nbio.core.sequence.template.CompoundSet; | |
| 26 | 26 | import org.biojava.nbio.core.sequence.template.Sequence; | |
| 27 | 27 | ||
| 28 | + import java.io.Serializable; | ||
| 28 | 29 | import java.util.*; | |
| 29 | 30 | ||
| 30 | 31 | /** | |
@@ -37,9 +38,13 @@ | |||
| 37 | 38 | * @author Scooter Willis | |
| 38 | 39 | * @author Mark Chapman | |
| 39 | 40 | */ | |
| 40 | - public class AminoAcidCompoundSet implements CompoundSet<AminoAcidCompound> { | ||
| 41 | + public class AminoAcidCompoundSet implements CompoundSet<AminoAcidCompound>, Serializable { | ||
| 41 | 42 | ||
| 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>(); | ||
| 43 | 48 | private final Map<String, AminoAcidCompound> aminoAcidCompoundCache3Letter = new HashMap<String, AminoAcidCompound>(); | |
| 44 | 49 | ||
| 45 | 50 | private final Map<AminoAcidCompound, Set<AminoAcidCompound>> equivalentsCache = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,13 @@ public abstract class AbstractCompound implements Compound { | |||
| 35 | 35 | private String description = null; | |
| 36 | 36 | private Float molecularWeight = null; | |
| 37 | 37 | ||
| 38 | + | ||
| 39 | + // Added an empty constructor for Serialization | ||
| 40 | + public AbstractCompound(){ | ||
| 41 | + this.base = null; | ||
| 42 | + this.upperedBase = null; | ||
| 43 | + } | ||
| 44 | + | ||
| 38 | 45 | public AbstractCompound(String base) { | |
| 39 | 46 | this.base = base; | |
| 40 | 47 | this.upperedBase = base.toUpperCase(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,10 +51,10 @@ | |||
| 51 | 51 | * | |
| 52 | 52 | */ | |
| 53 | 53 | public class BondMaker { | |
| 54 | - | ||
| 55 | - | ||
| 54 | + | ||
| 55 | + | ||
| 56 | 56 | private static final Logger logger = LoggerFactory.getLogger(BondMaker.class); | |
| 57 | - | ||
| 57 | + | ||
| 58 | 58 | /** | |
| 59 | 59 | * The types of bonds that are read from struct_conn (type specified in field conn_type_id) | |
| 60 | 60 | */ | |
@@ -68,8 +68,8 @@ public class BondMaker { | |||
| 68 | 68 | BOND_TYPES_TO_PARSE.add("covale_sugar"); | |
| 69 | 69 | BOND_TYPES_TO_PARSE.add("modres"); | |
| 70 | 70 | } | |
| 71 | - | ||
| 72 | - | ||
| 71 | + | ||
| 72 | + | ||
| 73 | 73 | /** | |
| 74 | 74 | * Maximum peptide (C - N) bond length considered for bond formation | |
| 75 | 75 | */ | |
@@ -249,7 +249,7 @@ public void formDisulfideBonds(List<SSBondImpl> disulfideBonds) { | |||
| 249 | 249 | } | |
| 250 | 250 | structure.setSSBonds(bonds); | |
| 251 | 251 | } | |
| 252 | - | ||
| 252 | + | ||
| 253 | 253 | private Bond formDisulfideBond(SSBondImpl disulfideBond) { | |
| 254 | 254 | try { | |
| 255 | 255 | Atom a = getAtomFromRecord("SG", "", "CYS", | |
@@ -258,25 +258,25 @@ private Bond formDisulfideBond(SSBondImpl disulfideBond) { | |||
| 258 | 258 | Atom b = getAtomFromRecord("SG", "", "CYS", | |
| 259 | 259 | disulfideBond.getChainID2(), disulfideBond.getResnum2(), | |
| 260 | 260 | disulfideBond.getInsCode2()); | |
| 261 | - | ||
| 261 | + | ||
| 262 | 262 | Bond ssbond = new BondImpl(a, b, 1); | |
| 263 | - | ||
| 263 | + | ||
| 264 | 264 | structure.addSSBond(ssbond); | |
| 265 | - | ||
| 265 | + | ||
| 266 | 266 | return ssbond; | |
| 267 | - | ||
| 267 | + | ||
| 268 | 268 | } catch (StructureException e) { | |
| 269 | 269 | // Note, in Calpha only mode the CYS SG's are not present. | |
| 270 | 270 | if (! params.isParseCAOnly()) { | |
| 271 | 271 | logger.warn("Could not find atoms specified in SSBOND record: {}",disulfideBond.toString()); | |
| 272 | 272 | } else { | |
| 273 | 273 | logger.debug("Could not find atoms specified in SSBOND record while parsing in parseCAonly mode."); | |
| 274 | 274 | } | |
| 275 | - | ||
| 275 | + | ||
| 276 | 276 | return null; | |
| 277 | 277 | } | |
| 278 | 278 | } | |
| 279 | - | ||
| 279 | + | ||
| 280 | 280 | /** | |
| 281 | 281 | * Creates bond objects from a LinkRecord as parsed from a PDB file | |
| 282 | 282 | * @param linkRecord | |
@@ -308,28 +308,34 @@ public void formLinkRecordBond(LinkRecord linkRecord) { | |||
| 308 | 308 | } else { | |
| 309 | 309 | logger.debug("Could not find atoms specified in LINK record while parsing in parseCAonly mode."); | |
| 310 | 310 | } | |
| 311 | - | ||
| 311 | + | ||
| 312 | 312 | } | |
| 313 | 313 | } | |
| 314 | - | ||
| 314 | + | ||
| 315 | 315 | public void formBondsFromStructConn(List<StructConn> structConn) { | |
| 316 | - | ||
| 316 | + | ||
| 317 | 317 | final String symop = "1_555"; // For now - accept bonds within origin asymmetric unit. | |
| 318 | - | ||
| 318 | + | ||
| 319 | 319 | List<Bond> ssbonds = new ArrayList<>(); | |
| 320 | - | ||
| 320 | + | ||
| 321 | 321 | for (StructConn conn : structConn) { | |
| 322 | - | ||
| 322 | + | ||
| 323 | 323 | 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 | + } | ||
| 328 | 334 | String insCode1 = ""; | |
| 329 | 335 | if (!conn.getPdbx_ptnr1_PDB_ins_code().equals("?")) insCode1 = conn.getPdbx_ptnr1_PDB_ins_code(); | |
| 330 | 336 | String insCode2 = ""; | |
| 331 | 337 | if (!conn.getPdbx_ptnr2_PDB_ins_code().equals("?")) insCode2 = conn.getPdbx_ptnr2_PDB_ins_code(); | |
| 332 | - | ||
| 338 | + | ||
| 333 | 339 | String seqId1 = conn.getPtnr1_auth_seq_id(); | |
| 334 | 340 | String seqId2 = conn.getPtnr2_auth_seq_id(); | |
| 335 | 341 | String resName1 = conn.getPtnr1_label_comp_id(); | |
@@ -340,13 +346,13 @@ public void formBondsFromStructConn(List<StructConn> structConn) { | |||
| 340 | 346 | if (!conn.getPdbx_ptnr1_label_alt_id().equals("?")) altLoc1 = conn.getPdbx_ptnr1_label_alt_id(); | |
| 341 | 347 | String altLoc2 = ""; | |
| 342 | 348 | if (!conn.getPdbx_ptnr2_label_alt_id().equals("?")) altLoc2 = conn.getPdbx_ptnr2_label_alt_id(); | |
| 343 | - | ||
| 349 | + | ||
| 344 | 350 | Atom a1 = null; | |
| 345 | 351 | Atom a2 = null; | |
| 346 | - | ||
| 352 | + | ||
| 347 | 353 | try { | |
| 348 | 354 | a1 = getAtomFromRecord(atomName1, altLoc1, resName1, chainId1, seqId1, insCode1); | |
| 349 | - | ||
| 355 | + | ||
| 350 | 356 | } catch (StructureException e) { | |
| 351 | 357 | String altLocStr1 = altLoc1.isEmpty()? "" : "(alt loc "+altLoc1+")"; | |
| 352 | 358 | 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) { | |||
| 359 | 365 | logger.warn("Could not find atom specified in struct_conn record: {}{}({}) in chain {}, atom {} {}", seqId2, insCode2, resName2, chainId2, atomName2, altLocStr2); | |
| 360 | 366 | continue; | |
| 361 | 367 | } | |
| 362 | - | ||
| 368 | + | ||
| 363 | 369 | ||
| 364 | 370 | // TODO: when issue 220 is implemented, add robust symmetry handling to allow bonds between symmetry-related molecules. | |
| 365 | 371 | if (!conn.getPtnr1_symmetry().equals(symop) || !conn.getPtnr2_symmetry().equals(symop) ) { | |
@@ -374,32 +380,31 @@ public void formBondsFromStructConn(List<StructConn> structConn) { | |||
| 374 | 380 | if (conn.getConn_type_id().equals("disulf")) { | |
| 375 | 381 | ssbonds.add(bond); | |
| 376 | 382 | } | |
| 377 | - | ||
| 383 | + | ||
| 378 | 384 | } | |
| 379 | - | ||
| 385 | + | ||
| 380 | 386 | // only for ss bonds we add a specific map in structure, all the rests are linked only from Atom.getBonds | |
| 381 | 387 | structure.setSSBonds(ssbonds); | |
| 382 | 388 | } | |
| 383 | - | ||
| 389 | + | ||
| 384 | 390 | private Atom getAtomFromRecord(String name, String altLoc, String resName, String chainID, String resSeq, String iCode) | |
| 385 | 391 | throws StructureException { | |
| 386 | - | ||
| 392 | + | ||
| 387 | 393 | if (iCode==null || iCode.isEmpty()) { | |
| 388 | 394 | iCode = " "; // an insertion code of ' ' is ignored | |
| 389 | 395 | } | |
| 390 | - | ||
| 391 | 396 | Chain chain = structure.getChainByPDB(chainID); | |
| 392 | 397 | ResidueNumber resNum = new ResidueNumber(chainID, Integer.parseInt(resSeq), iCode.charAt(0)); | |
| 393 | 398 | Group group = chain.getGroupByPDB(resNum); | |
| 394 | - | ||
| 399 | + | ||
| 395 | 400 | Group g = group; | |
| 396 | 401 | // there is an alternate location | |
| 397 | 402 | if (!altLoc.isEmpty()) { | |
| 398 | 403 | g = group.getAltLocGroup(altLoc.charAt(0)); | |
| 399 | 404 | if (g==null) | |
| 400 | 405 | throw new StructureException("Could not find altLoc code "+altLoc+" in group "+resSeq+iCode+" of chain "+ chainID); | |
| 401 | 406 | } | |
| 402 | - | ||
| 407 | + | ||
| 403 | 408 | return g.getAtom(name); | |
| 404 | 409 | } | |
| 405 | 410 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -929,8 +929,13 @@ private void linkCompounds() { | |||
| 929 | 929 | ||
| 930 | 930 | for (int i =0; i< structure.nrModels() ; i++){ | |
| 931 | 931 | 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 | + } | ||
| 934 | 939 | if (entityId==null) { | |
| 935 | 940 | // this can happen for instance if the cif file didn't have _struct_asym category at all | |
| 936 | 941 | // and thus we have no asymId2entityId mapping at all | |
@@ -1900,7 +1905,13 @@ private void addSites() { | |||
| 1900 | 1905 | String comp_id = siteGen.getLabel_comp_id(); // PDBName | |
| 1901 | 1906 | // Assumption: the author chain ID and residue number for the site is consistent with the original | |
| 1902 | 1907 | // 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 | + } | ||
| 1904 | 1915 | String auth_seq_id = siteGen.getAuth_seq_id(); // Res num | |
| 1905 | 1916 | ||
| 1906 | 1917 | String insCode = siteGen.getPdbx_auth_ins_code(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments