Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public InputStream getInputStream(URL u)
return openCompressedURL(u);
} else if (magic == GZIP_MAGIC ) {
return openGZIPURL(u);
} else if ( u.toString().endsWith(".gz")) {
} else if ( u.getPath().endsWith(".gz")) {
return openGZIPURL(u);
} else if ( u.toString().endsWith(".Z")) {
} else if ( u.getPath().endsWith(".Z")) {
// unix compressed
return openCompressedURL(u);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public void testGetNrAtoms(){
assertEquals("did not find the expected number of Atoms (1087), but got " + length,1087,length);
}

@SuppressWarnings("deprecation")
public void testGetSubRanges() throws StructureException {
String range;
Structure substr;
Expand Down Expand Up @@ -230,13 +231,13 @@ public void testGetSubRanges() throws StructureException {
try {
range = "7-10";
substr = StructureTools.getSubRanges(structure2, range);
fail("Illegal range '"+range+"'. Should throw StructureException");
} catch(StructureException ex) {} //expected
fail("Illegal range '"+range+"'. Should throw IllegalArgumentException");
} catch(IllegalArgumentException ex) {} //expected
try {
range = "A7-10";
substr = StructureTools.getSubRanges(structure2, range);
fail("Illegal range '"+range+"'. Should throw StructureException");
} catch(StructureException ex) {} //expected
fail("Illegal range '"+range+"'. Should throw IllegalArgumentException");
} catch(IllegalArgumentException ex) {} //expected
}

public void testRevisedConvention() throws IOException, StructureException{
Expand Down Expand Up @@ -319,6 +320,7 @@ public void testRevisedConvention() throws IOException, StructureException{
* Test some subranges that we used to have problems with
* @throws StructureException
*/
@SuppressWarnings("deprecation")
public void testGetSubRangesExtended() throws StructureException {
String range;
Structure substr;
Expand Down Expand Up @@ -379,6 +381,7 @@ public void testGetSubRangesExtended() throws StructureException {
* Test insertion codes
* @throws StructureException
*/
@SuppressWarnings("deprecation")
public void testGetSubRangesInsertionCodes() throws StructureException {
String range;
Structure substr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public class CathDomainTest {
public void test() {
String id = "1qvrC03";
CathDomain domain = CathFactory.getCathDatabase().getDomainByCathId(id);
assertEquals("1qvr.C_332-400,C_514-540", domain.getIdentifier());
assertEquals("1qvr.C_332-400,C_514-540", domain.toCanonical().getIdentifier());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,27 @@
*/
package org.biojava.nbio.structure.align.gui;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;

import org.biojava.nbio.structure.PassthroughIdentifier;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.StructureAlignment;
import org.biojava.nbio.structure.align.StructureAlignmentFactory;
import org.biojava.nbio.structure.align.ce.AbstractUserArgumentProcessor;
Expand All @@ -34,10 +53,6 @@
import org.biojava.nbio.structure.gui.util.PDBUploadPanel;
import org.biojava.nbio.structure.gui.util.ScopSelectPanel;
import org.biojava.nbio.structure.gui.util.StructurePairSelector;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;

/** A JFrame that allows to trigger a pairwise structure alignment,
* either from files in a directory,
Expand Down Expand Up @@ -368,8 +383,8 @@ private void calcAlignment() {
String name2 = "custom2";

if ( pos == 0){
name1 = tab1.getName1();
name2 = tab1.getName2();
name1 = tab1.getName1().getIdentifier();
name2 = tab1.getName2().getIdentifier();
} else {
name1 = s1.getName();
name2 = s2.getName();
Expand All @@ -389,6 +404,8 @@ private void calcAlignment() {
drawer.start();
} catch (StructureException e){
JOptionPane.showMessageDialog(null,"Could not align structures. Exception: " + e.getMessage());
} catch (IOException e) {
JOptionPane.showMessageDialog(null,"Could not align structures. Exception: " + e.getMessage());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.StructureTools;
import org.biojava.nbio.structure.align.MultipleStructureAligner;
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
Expand All @@ -49,7 +50,7 @@ public class MultipleAlignmentCalc implements AlignmentCalculationRunnable {
private static final Logger logger =
LoggerFactory.getLogger(MultipleAlignmentCalc.class);

private List<String> names;
private List<StructureIdentifier> names;
private List<Structure> structures;

private MultipleAlignmentGUI parent;
Expand All @@ -63,7 +64,7 @@ public class MultipleAlignmentCalc implements AlignmentCalculationRunnable {
* @param names
*/
public MultipleAlignmentCalc(MultipleAlignmentGUI parent,
List<Structure> structures, List<String> names) {
List<Structure> structures, List<StructureIdentifier> names) {

this.parent= parent;
this.structures = structures;
Expand All @@ -84,7 +85,7 @@ public void run() {
}

MultipleAlignment msa = algorithm.align(atomArrays);
msa.getEnsemble().setStructureNames(names);
msa.getEnsemble().setStructureIdentifiers(names);

MultipleAlignmentDisplay.display(msa);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.MultipleStructureAligner;
import org.biojava.nbio.structure.align.StructureAlignment;
import org.biojava.nbio.structure.align.StructureAlignmentFactory;
Expand Down Expand Up @@ -291,11 +292,11 @@ private void calcAlignment() {
return;
}

List<String> names = tab.getNames();
List<StructureIdentifier> names = tab.getNames();

String message = "aligning: ";
for (String name:names){
message += name + " ";
for (StructureIdentifier name:names){
message += name.getIdentifier() + " ";
}
System.out.println(message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@
*/
package org.biojava.nbio.structure.align.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.IOException;

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.ResidueRange;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureTools;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.SubstructureIdentifier;
import org.biojava.nbio.structure.align.util.AtomCache;
import org.biojava.nbio.structure.align.util.UserConfiguration;
import org.biojava.nbio.structure.align.webstart.WebStartMain;
import org.biojava.nbio.structure.gui.util.StructurePairSelector;
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.biojava.nbio.structure.io.MMCIFFileReader;
import org.biojava.nbio.structure.io.PDBFileReader;
import org.biojava.nbio.structure.io.StructureProvider;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;


/** A Panel that allows user to specify PDB & chain ID, as well as sub-ranges
Expand Down Expand Up @@ -100,101 +105,46 @@ public SelectPDBPanel(boolean show2PDBs) {
this.add(vBox);
}

public String getName1() {

public StructureIdentifier getName1() {
String pdbId = f1.getText().trim();
String chainId = c1.getText().trim();

String name = f1.getText().trim();

if ( ! chainId.equals("") ){
name += "." + chainId;
String range = r1.getText().trim();

// 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 name;
return new SubstructureIdentifier(pdbId);
}
public String getName2() {
public StructureIdentifier getName2() {
String pdbId = f2.getText().trim();
String chainId = c2.getText().trim();

String name = f2.getText().trim();

if ( ! chainId.equals("") ){
name += "." + chainId;
String range = r2.getText().trim();

// 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 name;
return new SubstructureIdentifier(pdbId);
}
@Override
public Structure getStructure1() throws StructureException{
return fromPDB(f1,c1,r1);
public Structure getStructure1() throws StructureException, IOException{
return getStructure(getName1());
}

@Override
public Structure getStructure2() throws StructureException{
return fromPDB(f2,c2,r2);
public Structure getStructure2() throws StructureException, IOException{
return getStructure(getName2());
}






private Structure fromPDB(JTextField f, JTextField c,JTextField r) throws StructureException{
String pdb = f.getText().trim();

private Structure getStructure(StructureIdentifier name) throws IOException, StructureException {
UserConfiguration config = WebStartMain.getWebStartConfig();

if ( pdb.length() < 4) {
f.setText("!!!");
return null;
}

String chain = c.getText().trim();
if ( debug )
System.out.println("file :" + pdb + " " + chain);


String range = r.getText().trim();

String fileFormat = config.getFileFormat();

StructureProvider reader = null;
if ( fileFormat.equals(UserConfiguration.PDB_FORMAT)){
PDBFileReader re = new PDBFileReader(config.getPdbFilePath());
re.setFetchBehavior(config.getFetchBehavior());
reader = re;
} else if ( fileFormat.equals(UserConfiguration.MMCIF_FORMAT)){
MMCIFFileReader re = new MMCIFFileReader(config.getPdbFilePath());
re.setFetchBehavior(config.getFetchBehavior());
reader = re;
} else {
throw new StructureException("Unkown file format " + fileFormat);
}

FileParsingParameters params = new FileParsingParameters();
params.setAlignSeqRes(false);
reader.setFileParsingParameters(params);


Structure structure ;
try {
structure = reader.getStructureById(pdb);
} catch (IOException e) {
throw new StructureException("Could not read structure " + pdb ,e);
}


//System.out.println(" got range: " + range);
if ( range != null && ( ! range.equals(""))){
if ( structure.getName() == null || structure.getName().equals(""))
structure.setName(pdb);
Structure s = StructureTools.getSubRanges(structure, range);
//System.out.println("got atoms: " + StructureTools.getAtomCAArray(s).length);
return s;
}
Structure s = StructureTools.getReducedStructure(structure,chain);
//System.out.println("got atoms: " + StructureTools.getAtomCAArray(s).length);
if ( s.getName() == null || s.getName().equals(""))
s.setName(pdb+"."+chain);
return s;

AtomCache cache = new AtomCache(config);
return cache.getStructure(name);
}

private Box getPDBFilePanel(int pos ,JTextField f, JTextField c, JTextField r){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.biojava.nbio.structure.PDBHeader;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.gui.MenuCreator;
import org.biojava.nbio.structure.align.gui.MultipleAlignmentDisplay;
import org.biojava.nbio.structure.align.gui.MultipleAlignmentGUI;
Expand Down Expand Up @@ -181,7 +182,7 @@ public void actionPerformed(ActionEvent e) {

for (int str=0; str<multAln.size(); str++){
JCheckBox structureSelection = new JCheckBox(
multAln.getEnsemble().getStructureNames().get(str));
multAln.getEnsemble().getStructureIdentifiers().get(str).getIdentifier());
hBox0.add(structureSelection);
hBox0.add(Box.createGlue());
structureSelection.setSelected(true);
Expand Down Expand Up @@ -334,6 +335,7 @@ public void itemStateChanged(ItemEvent e) {
resetDisplay();
}

@Override
protected void initCoords(){
try {
if ( multAln == null ){
Expand All @@ -348,8 +350,8 @@ protected void initCoords(){
String title = multAln.getEnsemble().getAlgorithmName() +
" V." +multAln.getEnsemble().getVersion() + " : ";

for (String name:multAln.getEnsemble().getStructureNames()){
title += name + " ";
for (StructureIdentifier name:multAln.getEnsemble().getStructureIdentifiers()){
title += name.getIdentifier() + " ";
}
Structure artificial = MultipleAlignmentDisplay.
getAlignedStructure(transformedAtoms);
Expand Down Expand Up @@ -534,6 +536,7 @@ private static void printJmolScript4Block(Atom[] atoms,
jmol.append(buf);
}

@Override
public void resetDisplay() {

if (multAln != null && transformedAtoms != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ private Structure getStructure(String domainID) throws StructureException{
//String cacheLocation = config.getPdbFilePath();

AtomCache cache = new AtomCache(config);
cache.setStrictSCOP(false);

Structure s = null;
try {
Expand Down
Loading