Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6c22796
Support for extended PDBID PDB_nnnnNXXX
aalhossary Jul 27, 2021
dc12461
Some deprecated functions removal
aalhossary Jul 31, 2021
7b08387
Fix typo
aalhossary Aug 3, 2021
c39632c
Targeted most of Spencer's comments
aalhossary Aug 4, 2021
7dd8528
Fixed a bug in PDBId.equals() method
aalhossary Aug 4, 2021
e8466b9
Changing PDBID in SCOP record to lower case
aalhossary Aug 4, 2021
12efad9
public static PDBId field XXXX
aalhossary Sep 22, 2021
d4dfc95
Behavior is now an enum
aalhossary Oct 1, 2021
22e9158
Expose Pattern objects instead of Strings
aalhossary Oct 1, 2021
5c6bcdc
ID stored internally in a reduced format (without initial "PDB_" prefix)
aalhossary Oct 1, 2021
76112f0
Enhancements and bug fix
aalhossary Oct 2, 2021
d95e561
Added BDBId Unit test
aalhossary Oct 2, 2021
f54dd7d
Merge branch 'master' into Support_Extended_PDBID
aalhossary Oct 2, 2021
727aff6
Added @Deprecated codeTag
aalhossary Oct 2, 2021
960a1e6
Adding more TODOs
aalhossary Oct 2, 2021
605c6f8
more replacement of deprecated methods
aalhossary Oct 2, 2021
ec53cee
Removed PDBIdException
aalhossary Oct 9, 2021
fd48eba
review and untouch regular expressions
aalhossary Oct 9, 2021
84d9654
Un-deprecate, copy javadoc, and remove @author on methods
aalhossary Oct 10, 2021
e900fe5
Remove NullPointerException
aalhossary Oct 10, 2021
711fb8a
Bug fix
aalhossary Oct 10, 2021
f92db27
clean commented out code
aalhossary Oct 10, 2021
d9e15e0
Update CHANGELOG
aalhossary Oct 10, 2021
b410f16
Fix unit test
aalhossary Oct 13, 2021
6c8d267
PdbPair does not accept null
aalhossary Oct 12, 2021
a03a657
Addressing reviewer's comments
aalhossary Oct 13, 2021
a55aa95
Change capitalization state
aalhossary Oct 14, 2021
732a2c2
Fix probable NPE + keep consistent PdbId method naming convention
aalhossary Oct 14, 2021
34cb49e
Addressed some of the reviewer's comments.
aalhossary Oct 14, 2021
40a55d2
Use JUnit 5
aalhossary Oct 14, 2021
141d667
PdbId class Documentation
aalhossary Oct 15, 2021
c91a4dc
JavaDoc style update
aalhossary Oct 15, 2021
9ce50fe
Minor updates
aalhossary Oct 15, 2021
0fb6742
Reverting a wrong optimization
aalhossary Oct 15, 2021
02bfee4
Merge branch 'biojavaorigin/master' into Support_Extended_PDBID
aalhossary Oct 16, 2021
0d96963
Adding BioJava development code
aalhossary Oct 16, 2021
87fbc10
Javadoc
aalhossary Oct 21, 2021
17f366e
XXXX PdbId objects are not equal unless they are the same object
aalhossary Oct 22, 2021
ef9cf3f
No more XXXX. ANY malformed PdbId gracefully set to null
aalhossary Oct 23, 2021
02974cd
Addressing Reviewer's comments
aalhossary Oct 26, 2021
108fe97
Removing TODOs
aalhossary Oct 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package org.biojava.nbio.structure.test;

import org.biojava.nbio.structure.*;
import org.biojava.nbio.structure.PDBId.PDBIdException;
import org.biojava.nbio.structure.align.util.AtomCache;
import org.biojava.nbio.structure.io.CifFileReader;
import org.biojava.nbio.structure.io.FileParsingParameters;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void setUp() throws Exception {


@Test
public void test1a4wPDBFile() throws IOException
public void test1a4wPDBFile() throws IOException, PDBIdException
{

// structure = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package org.biojava.nbio.structure.test.cath;

import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.cath.CathDomain;
import org.biojava.nbio.structure.cath.CathFactory;
import org.junit.Test;
Expand All @@ -33,9 +34,9 @@
*/
public class CathDomainTest {
@Test
public void test() {
public void test() throws StructureException {
String id = "1qvrC03";
CathDomain domain = CathFactory.getCathDatabase().getDomainByCathId(id);
assertEquals("1qvr.C_332-400,C_514-540", domain.toCanonical().getIdentifier());
assertEquals("1QVR.C_332-400,C_514-540", domain.toCanonical().getIdentifier());
Comment thread
aalhossary marked this conversation as resolved.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.regex.Pattern;

import org.biojava.nbio.core.util.ConcurrencyTools;
import org.biojava.nbio.structure.PDBId.PDBIdException;
import org.biojava.nbio.structure.ResidueNumber;
import org.biojava.nbio.structure.ResidueRange;
import org.biojava.nbio.structure.StructureException;
Expand Down Expand Up @@ -155,7 +156,7 @@ private void matchNames(String pdbId,String[] expected,List<EcodDomain> actual)
}

@Test
public void testParsing() throws IOException {
public void testParsing() throws IOException, PDBIdException {
EcodDatabase ecod = EcodFactory.getEcodDatabase(VERSION);

String ecodId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;

import org.biojava.nbio.structure.PDBId;
import org.biojava.nbio.structure.PDBId.PDBIdException;
import org.biojava.nbio.structure.ResidueRange;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
Expand Down Expand Up @@ -105,31 +108,33 @@ public SelectPDBPanel(boolean show2PDBs) {
this.add(vBox);
}

public StructureIdentifier getName1() {
String pdbId = f1.getText().trim();
public StructureIdentifier getName1() throws PDBIdException {
String id = f1.getText().trim();
String chainId = c1.getText().trim();
String range = r1.getText().trim();


PDBId pdbId = new PDBId(id);
// Prefer range over chain
if( ! range.isEmpty() ) {
return new SubstructureIdentifier(pdbId, ResidueRange.parseMultiple(range));
} else if ( ! chainId.isEmpty() ){
return new SubstructureIdentifier(pdbId, ResidueRange.parseMultiple(chainId));
}
return new SubstructureIdentifier(pdbId);
return new SubstructureIdentifier(pdbId, new ArrayList<ResidueRange>());
}
public StructureIdentifier getName2() {
String pdbId = f2.getText().trim();
public StructureIdentifier getName2() throws PDBIdException {
String id = f2.getText().trim();
String chainId = c2.getText().trim();
String range = r2.getText().trim();


PDBId pdbId = new PDBId(id);
// Prefer range over chain
if( ! range.isEmpty() ) {
return new SubstructureIdentifier(pdbId, ResidueRange.parseMultiple(range));
} else if ( ! chainId.isEmpty() ){
return new SubstructureIdentifier(pdbId, ResidueRange.parseMultiple(chainId));
}
return new SubstructureIdentifier(pdbId);
return new SubstructureIdentifier(pdbId, new ArrayList<ResidueRange>());
}
@Override
public Structure getStructure1() throws StructureException, IOException{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ private Structure fromPDB(JTextField f, JTextField c) throws StructureException{
if ( debug)
System.out.println("using chain " + chain + " for structure " + structure1.getPDBCode());
Chain c1 = structure1.getPolyChainByPDB(chain);
tmp1.setPDBCode(structure1.getPDBCode());
// tmp1.setPDBId(structure1.getPDBId()); // Isn't it a duplicate?
Comment thread
aalhossary marked this conversation as resolved.
Outdated
tmp1.setPDBHeader(structure1.getPDBHeader());
tmp1.setPDBCode(structure1.getPDBCode());
tmp1.setPDBId(structure1.getPDBId());
tmp1.addChain(c1);
System.out.println("ok");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ private Structure fromPDB(JTextField f, JTextField c) throws StructureException{
if ( debug)
System.out.println("using chain " + chain + " for structure " + structure1.getPDBCode());
Chain c1 = structure1.getPolyChainByPDB(chain);
tmp1.setPDBCode(structure1.getPDBCode());
// tmp1.setPDBId(structure1.getPDBId()); //Isn't it duplicate?
Comment thread
aalhossary marked this conversation as resolved.
Outdated
tmp1.setPDBHeader(structure1.getPDBHeader());
tmp1.setPDBCode(structure1.getPDBCode());
tmp1.setPDBId(structure1.getPDBId());
tmp1.addChain(c1);
System.out.println("ok");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,34 @@
package org.biojava.nbio.structure.gui.util;


import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.biojava.nbio.structure.ResidueRange;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureTools;
import org.biojava.nbio.structure.SubstructureIdentifier;
import org.biojava.nbio.structure.align.util.UserConfiguration;
import org.biojava.nbio.structure.io.CifFileReader;
import org.biojava.nbio.structure.io.PDBFileReader;
import org.biojava.nbio.structure.io.StructureIOFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;

/** A JPanel to upload 2 custom PDB files.
*
* @author Andreas Prlic
Expand Down Expand Up @@ -66,9 +77,9 @@ public class PDBUploadPanel
JTextField chain1;
JTextField chain2;

public static JComboBox getFileFormatSelect(){
JComboBox fileType = new JComboBox();
fileType = new JComboBox(new String[] {UserConfiguration.PDB_FORMAT,UserConfiguration.MMCIF_FORMAT});
public static JComboBox<String> getFileFormatSelect(){
JComboBox<String> fileType = new JComboBox<>();
fileType = new JComboBox<String>(new String[] {UserConfiguration.PDB_FORMAT,UserConfiguration.MMCIF_FORMAT});
fileType.setSelectedIndex(0);
fileType.setMaximumSize(new Dimension(10,50));

Expand Down Expand Up @@ -150,7 +161,10 @@ private Structure getStructure(JTextField filePath,JTextField chainId) throws St
throw new StructureException(e);
}

Structure reduced = StructureTools.getReducedStructure(s, chainId.getText());
// Structure reduced = StructureTools.getReducedStructure(s, chainId.getText());
// Structure reduced = new SubstructureIdentifier(s.getPDBId().getId()+"."+ chainId.getText()).reduce(s); //TODO double check this
Structure reduced = new SubstructureIdentifier(s.getPDBId(),
Arrays.asList(new ResidueRange(chainId.getText(), (String) null, null))).reduce(s);

String fileURL = "";
try {
Expand All @@ -169,7 +183,7 @@ private Structure getStructure(JTextField filePath,JTextField chainId) throws St
e.printStackTrace();
}

reduced.setPDBCode(fileURL);
reduced.setPDBCode(fileURL); //FIXME This usage seems wrong and should be changed.
reduced.setName(fileURL);
return reduced;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package demo;

import org.biojava.nbio.structure.Chain;
import org.biojava.nbio.structure.PDBId.PDBIdException;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.io.cif.CifStructureConverter;

Expand All @@ -41,7 +42,7 @@ public static void main(String[] args) throws Exception {
convert(inFile, outFile);
}

public static void convert(File inFile, File outFile) throws IOException {
public static void convert(File inFile, File outFile) throws IOException, PDBIdException {
// now get the protein structure.
Structure cifStructure = CifStructureConverter.fromPath(inFile.toPath());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,51 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.biojava.nbio.structure.PDBId.PDBIdException;
import org.biojava.nbio.structure.align.util.AtomCache;

public class BioAssemblyIdentifier implements StructureIdentifier {

private static final long serialVersionUID = -356206725119993449L;

private String pdbCode;
private PDBId pdbId;
private int biolNr;

public static final Pattern BIO_NAME_PATTERN = Pattern.compile("^(?:BIO:)([0-9][a-z0-9]{3})(?::([0-9]+))?$", Pattern.CASE_INSENSITIVE);

public BioAssemblyIdentifier(String name) {
public BioAssemblyIdentifier(String name) throws PDBIdException {
Matcher match = BIO_NAME_PATTERN.matcher(name);
if(! match.matches() ) {
throw new IllegalArgumentException("Invalid BIO identifier");
}
pdbCode = match.group(1);
pdbId = new PDBId(match.group(1));
if(match.group(2) != null) {
biolNr = Integer.parseInt(match.group(2));
} else {
biolNr = 1;
}
}

public BioAssemblyIdentifier(String pdbCode, int biolNr) {
this.pdbCode = pdbCode;
/**
* @param pdbCode
* @param biolNr
* @throws PDBIdException
* @Deprecated use {@link #BioAssemblyIdentifier(PDBId, int)} instead
*/
public BioAssemblyIdentifier(String pdbCode, int biolNr) throws PDBIdException {
this(new PDBId(pdbCode), biolNr);
}
public BioAssemblyIdentifier(PDBId pdbId, int biolNr) {
this.pdbId = pdbId;
this.biolNr = biolNr;
}

@Override
public String getIdentifier() {
if( biolNr < 0) {
return "BIO:"+pdbCode;
return "BIO:"+pdbId.getId();
} else {
return String.format("BIO:%s:%d",pdbCode,biolNr);
return String.format("BIO:%s:%d",pdbId.getId(),biolNr);
}
}
@Override
Expand All @@ -70,12 +80,12 @@ public String toString() {
@Override
public Structure loadStructure(AtomCache cache) throws StructureException,
IOException {
return cache.getBiologicalAssembly(pdbCode, biolNr, AtomCache.DEFAULT_BIOASSEMBLY_STYLE);
return cache.getBiologicalAssembly(pdbId, biolNr, AtomCache.DEFAULT_BIOASSEMBLY_STYLE);
}

@Override
public SubstructureIdentifier toCanonical() throws StructureException {
return new SubstructureIdentifier(pdbCode, new ArrayList<ResidueRange>());
return new SubstructureIdentifier(pdbId, new ArrayList<ResidueRange>());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package org.biojava.nbio.structure;

import org.biojava.nbio.structure.PDBId.PDBIdException;
import org.biojava.nbio.structure.quaternary.BioAssemblyInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -48,7 +49,8 @@ public class PDBHeader implements PDBRecord {

private String title;
private String description;
private String idCode;
// private String idCode;
Comment thread
aalhossary marked this conversation as resolved.
Outdated
private PDBId pdbId;
private String classification;

private Date depDate;
Expand Down Expand Up @@ -449,20 +451,39 @@ public boolean equals(PDBHeader other){
*
* @return the PDB identifier
* @see #setIdCode(String)
* @deprecated use {@link #getPdbId()}
*/
public String getIdCode() {
return idCode;
if(this.pdbId == null)
return null;
return this.pdbId.getId();
}

/** The PDB code for this protein structure.
*
* @param idCode the PDB identifier
* @see #getIdCode()
*
* @deprecated use {@link #setPDBId(PDBId)}
*/
public void setIdCode(String idCode) {
this.idCode = idCode;
if(idCode == null) {
this.pdbId = null;
}else {
try {
this.pdbId = new PDBId(idCode);
} catch (PDBIdException e) {
throw new IllegalArgumentException(e);
}
}
}

public PDBId getPdbId() {
Comment thread
aalhossary marked this conversation as resolved.
Outdated
return pdbId;
}

public void setPDBId(PDBId pdbId) {
Comment thread
aalhossary marked this conversation as resolved.
Outdated
this.pdbId = pdbId;
}

public String getClassification() {
return classification;
Expand Down
Loading