Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for min and max seq. identity for pseudosymmetry cases #13

Merged
merged 1 commit into from
Jun 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/main/java/demo/DemoOrientBioAssembly.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static boolean analyzeSymmetry(Structure s,String pdbID, int biolAssembl
System.out.println("=================");
System.out.println("Sequence ID : " + parameters.getSequenceIdentityThreshold() );
System.out.println("Stoichiometry : " + calc.getSubunits().getStoichiometry());
System.out.println("Pseudostoichiometry: " + calc.getSubunits().isPseudoStiochiometric());
System.out.println("Pseudostoichiometry: " + calc.getSubunits().isPseudoStoichiometric());
System.out.println("Point Group : " + calc.getRotationGroup().getPointGroup());

System.out.println("Symmetry RMSD : " + String.format("%.2f",calc.getRotationGroup().getAverageTraceRmsd()));
Expand Down Expand Up @@ -148,7 +148,7 @@ private static boolean analyzeSymmetry(Structure s,String pdbID, int biolAssembl
}

System.out.println("=================");
return calc.getSubunits().isPseudoStiochiometric();
return calc.getSubunits().isPseudoStoichiometric();
} else {
System.out.println("No protein chains found");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public boolean orient(){
System.out.println("Results for " + Math.round(parameters.getSequenceIdentityThreshold()*100) + "% sequence identity threshold:");
System.out.println();
System.out.println("Global symmetry:");
System.out.println("Stoichiometry : " + globalSymmetry.getSubunits().getStoichiometry());
System.out.println("Pseudostoichiometry : " + globalSymmetry.getSubunits().isPseudoStiochiometric());
System.out.println("Point group : " + globalSymmetry.getRotationGroup().getPointGroup());
System.out.println("Symmetry RMSD : " + (float) globalSymmetry.getRotationGroup().getAverageTraceRmsd());
System.out.println("Stoichiometry : " + globalSymmetry.getSubunits().getStoichiometry());
System.out.println("Pseudostoichiometry : " + globalSymmetry.getSubunits().isPseudoStoichiometric());
System.out.println("Min sequence identity : " + Math.round(globalSymmetry.getSubunits().getMinSequenceIdentity()*100));
System.out.println("Max sequence identity : " + Math.round(globalSymmetry.getSubunits().getMaxSequenceIdentity()*100));
System.out.println("Point group : " + globalSymmetry.getRotationGroup().getPointGroup());
System.out.println("Symmetry RMSD : " + (float) globalSymmetry.getRotationGroup().getAverageTraceRmsd());
}

axisTransformation = new AxisTransformation(globalSymmetry);
Expand All @@ -97,10 +99,12 @@ public boolean orient(){
AxisTransformation at = new AxisTransformation(localSymmetry);
System.out.println();
System.out.println("Results for " + Math.round(parameters.getSequenceIdentityThreshold()*100) + "% sequence identity threshold:");
System.out.println("Stoichiometry : " + localSymmetry.getSubunits().getStoichiometry());
System.out.println("Pseudostoichiometry : " + localSymmetry.getSubunits().isPseudoStiochiometric());
System.out.println("Point group : " + localSymmetry.getRotationGroup().getPointGroup());
System.out.println("Symmetry RMSD : " + (float) localSymmetry.getRotationGroup().getAverageTraceRmsd());
System.out.println("Stoichiometry : " + localSymmetry.getSubunits().getStoichiometry());
System.out.println("Pseudostoichiometry : " + localSymmetry.getSubunits().isPseudoStoichiometric());
System.out.println("Min sequence identity : " + Math.round(localSymmetry.getSubunits().getMinSequenceIdentity()*100));
System.out.println("Max sequence identity : " + Math.round(localSymmetry.getSubunits().getMaxSequenceIdentity()*100));
System.out.println("Point group : " + localSymmetry.getRotationGroup().getPointGroup());
System.out.println("Symmetry RMSD : " + (float) localSymmetry.getRotationGroup().getAverageTraceRmsd());
System.out.println();
JmolSymmetryScriptGenerator gen = JmolSymmetryScriptGenerator.getInstance(at, "l"+count);
if (count == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void orient(Structure structure) {
// initialize with default parameters
QuatSymmetryParameters params = new QuatSymmetryParameters();
params.setSequenceIdentityThreshold(0.95);
// params.setStructuralAlignmentOnly(true);
params.setStructuralAlignmentOnly(true);
params.setVerbose(verbose);

System.out.println("Default parameters:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ private Subunits createGlobalSubunits() {
Subunits subunits = new Subunits(chainClusterer.getCalphaCoordinates(),
chainClusterer.getSequenceClusterIds(),
chainClusterer.getPseudoStoichiometry(),
chainClusterer.getMinSequenceIdentity(),
chainClusterer.getMaxSequenceIdentity(),
chainClusterer.getFolds(),
chainClusterer.getChainIds(),
chainClusterer.getModelNumbers());
Expand All @@ -166,13 +168,17 @@ private Subunits createLocalSubunit(List<Integer> subCluster) {
List<Point3d[]> subCalphaCoordinates = new ArrayList<Point3d[]>(subCluster.size());
List<Integer> subSequenceIds = new ArrayList<Integer>(subCluster.size());
List<Boolean> subPseudoStoichiometry = new ArrayList<Boolean>(subCluster.size());
List<Double> subMinSequenceIdentity = new ArrayList<Double>(subCluster.size());
List<Double> subMaxSequenceIdentity = new ArrayList<Double>(subCluster.size());
List<String> subChainIds = new ArrayList<String>(subCluster.size());
List<Integer> subModelNumbers = new ArrayList<Integer>(subCluster.size());

for (int index: subCluster) {
subCalphaCoordinates.add(chainClusterer.getCalphaCoordinates().get(index));
subSequenceIds.add(chainClusterer.getSequenceClusterIds().get(index));
subPseudoStoichiometry.add(chainClusterer.getPseudoStoichiometry().get(index));
subMinSequenceIdentity.add(chainClusterer.getMinSequenceIdentity().get(index));
subMaxSequenceIdentity.add(chainClusterer.getMaxSequenceIdentity().get(index));
subChainIds.add(chainClusterer.getChainIds().get(index));
subModelNumbers.add(chainClusterer.getModelNumbers().get(index));
}
Expand All @@ -184,6 +190,8 @@ private Subunits createLocalSubunit(List<Integer> subCluster) {
Subunits subunits = new Subunits(subCalphaCoordinates,
subSequenceIds,
subPseudoStoichiometry,
subMinSequenceIdentity,
subMaxSequenceIdentity,
subFolds,
subChainIds,
subModelNumbers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class SequenceAlignmentCluster {

private int alignmentLength = 0;
private boolean pseudoStoichiometric = false;
private double minSequenceIdentity = 100;
private double maxSequenceIdentity = 0;
private double minSequenceIdentity = 1.0;
private double maxSequenceIdentity = 0.0;

private boolean modified = true;

Expand All @@ -36,10 +36,16 @@ public boolean isPseudoStoichiometric() {
}

public double getMinSequenceIdentity() {
if (! isPseudoStoichiometric()) {
return 1.0;
}
return minSequenceIdentity;
}

public double getMaxSequenceIdentity() {
if (! isPseudoStoichiometric()) {
return 1.0;
}
return maxSequenceIdentity;
}

Expand All @@ -49,11 +55,7 @@ public void addUniqueSequenceList(UniqueSequenceList sequenceList) {
}

public int getSequenceCount() {
int count = 0;
for (UniqueSequenceList list: uniqueSequenceList) {
count += list.getChainCount();
}
return count;
return uniqueSequenceList.size();
}

public int getSequenceAlignmentLength() {
Expand All @@ -68,29 +70,23 @@ public List<UniqueSequenceList> getUniqueSequenceList() {
public List<String> getChainIds() {
List<String> ids = new ArrayList<String>();
for (UniqueSequenceList list: uniqueSequenceList) {
for (int i = 0, n = list.getChainCount(); i < n; i++) {
ids.add(list.getChainId(i));
}
ids.add(list.getChainId());
}
return ids;
}

public List<Integer> getModelNumbers() {
List<Integer> numbers = new ArrayList<Integer>();
for (UniqueSequenceList list: uniqueSequenceList) {
for (int i = 0, n = list.getChainCount(); i < n; i++) {
numbers.add(list.getModelNumber(i));
}
numbers.add(list.getModelNumber());
}
return numbers;
}

public List<Integer> getStructureIds() {
List<Integer> numbers = new ArrayList<Integer>();
for (UniqueSequenceList list: uniqueSequenceList) {
for (int i = 0, n = list.getChainCount(); i < n; i++) {
numbers.add(list.getStructureId(i));
}
numbers.add(list.getStructureId());
}
return numbers;
}
Expand Down Expand Up @@ -129,7 +125,7 @@ public boolean identityMatch(Atom[] cAlphaAtoms, String chainId, int modelNumber
if (seqMatch) {
List<Integer> alig1 = new ArrayList<Integer>();
List<Integer> alig2 = new ArrayList<Integer>();
Atom[] referenceAtoms = u.getReferenceChain();
Atom[] referenceAtoms = u.getCalphaAtoms();
int inCommon = alignIdenticalSequence(referenceAtoms, cAlphaAtoms, alig1, alig2);
// System.out.println("in common: " + inCommon);

Expand All @@ -154,8 +150,8 @@ public int[][][] alignClustersByStructure(SequenceAlignmentCluster cluster) {
pseudoStoichiometric = false;

int[][][] alignment = null;
Atom[] referenceAtoms1 = this.getUniqueSequenceList().get(0).getReferenceChain();
Atom[] referenceAtoms2 = cluster.getUniqueSequenceList().get(0).getReferenceChain();
Atom[] referenceAtoms1 = this.getUniqueSequenceList().get(0).getCalphaAtoms();
Atom[] referenceAtoms2 = cluster.getUniqueSequenceList().get(0).getCalphaAtoms();

double alignmentLengthFraction = (double)Math.min(referenceAtoms1.length, referenceAtoms2.length) /
Math.max(referenceAtoms1.length, referenceAtoms2.length);
Expand Down Expand Up @@ -318,14 +314,12 @@ private void createAlignedCAlphaAtoms() {
alignmentIndices.add(alignment2.get(i));
}
}
for (int i = 0; i < u.getChainCount(); i++) {
Atom[] unalignedAtoms = u.getChain(i);
Atom[] alignedAtoms = new Atom[alignmentIndices.size()];
for (int j = 0; j < alignedAtoms.length; j++) {
alignedAtoms[j] = unalignedAtoms[alignmentIndices.get(j)];
}
alignedCAlphaAtoms.add(alignedAtoms);
Atom[] unalignedAtoms = u.getCalphaAtoms();
Atom[] alignedAtoms = new Atom[alignmentIndices.size()];
for (int j = 0; j < alignedAtoms.length; j++) {
alignedAtoms[j] = unalignedAtoms[alignmentIndices.get(j)];
}
alignedCAlphaAtoms.add(alignedAtoms);
}
}

Expand Down
36 changes: 26 additions & 10 deletions src/main/java/org/biojava3/structure/quaternary/core/Subunits.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class Subunits {
private List<Point3d[]> caCoords = Collections.emptyList();
private List<Integer> sequenceClusterIds = Collections.emptyList();
private List<Boolean> pseudoStoichiometry = Collections.emptyList();
private List<Double> minSequenceIdentity = Collections.emptyList();
private List<Double> maxSequenceIdentity = Collections.emptyList();
private List<String> chainIds = Collections.emptyList();
private List<Integer> modelNumbers = Collections.emptyList();
private List<Integer> folds = Collections.emptyList();
Expand All @@ -35,13 +37,15 @@ public class Subunits {
private Point3d centroid;
private MomentsOfInertia momentsOfInertia = new MomentsOfInertia();

public Subunits(List<Point3d[]> caCoords, List<Integer> sequenceClusterIds, List<Boolean> pseudoStoichiometry, List<Integer> folds, List<String> chainIds, List<Integer> modelNumbers) {
this.caCoords = caCoords;
this.sequenceClusterIds = sequenceClusterIds;
this.pseudoStoichiometry = pseudoStoichiometry;
this.folds = folds;
this.chainIds = chainIds;
this.modelNumbers = modelNumbers;
public Subunits(List<Point3d[]> caCoords, List<Integer> sequenceClusterIds, List<Boolean> pseudoStoichiometry, List<Double> minSequenceIdentity, List<Double> maxSequenceIdentity, List<Integer> folds, List<String> chainIds, List<Integer> modelNumbers) {
this.caCoords = caCoords;
this.sequenceClusterIds = sequenceClusterIds;
this.pseudoStoichiometry = pseudoStoichiometry;
this.minSequenceIdentity = minSequenceIdentity;
this.maxSequenceIdentity = maxSequenceIdentity;
this.folds = folds;
this.chainIds = chainIds;
this.modelNumbers = modelNumbers;
}

public List<Point3d[]> getTraces() {
Expand All @@ -60,7 +64,7 @@ public List<Integer> getSequenceClusterIds() {
return sequenceClusterIds;
}

public boolean isPseudoStiochiometric() {
public boolean isPseudoStoichiometric() {
for (Boolean b: pseudoStoichiometry) {
if (b) {
return true;
Expand All @@ -69,10 +73,22 @@ public boolean isPseudoStiochiometric() {
return false;
}

public List<Boolean> getPseudoStoichiometry() {
return pseudoStoichiometry;
public double getMinSequenceIdentity() {
double minId = 1.0;
for (double seqId: minSequenceIdentity) {
minId = Math.min(seqId, minId);
}
return minId;
}

public double getMaxSequenceIdentity() {
double maxId = 1.0;
for (double seqId: maxSequenceIdentity) {
maxId = Math.min(seqId, maxId);
}
return maxId;
}

public List<String> getChainIds() {
return chainIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ public class UniqueSequenceList {
private String seqResSequence = "";
private List<Integer> alignment1 = null;
private List<Integer> alignment2 = null;
private List<Atom[]> caAtoms = new ArrayList<Atom[]>();
private List<String> chainIds = new ArrayList<String>();
private List<Integer> modelNumbers = new ArrayList<Integer>();
private List<Integer> structureIds = new ArrayList<Integer>();
private Atom[] caAtoms = null;
private String chainId = null;
private Integer modelNumber = null;
private Integer structureId = null;

public UniqueSequenceList(Atom[] cAlphaAtoms, String chainId, int modelNumber, int structureId, String seqResSequence) {
this.caAtoms.add(cAlphaAtoms);
this.chainIds.add(chainId);
this.modelNumbers.add(modelNumber);
this.structureIds.add(structureId);
this.caAtoms = cAlphaAtoms;
this.chainId = chainId;
this.modelNumber = modelNumber;
this.structureId = structureId;
this.seqResSequence = seqResSequence;
this.sequenceString = getSequenceString(cAlphaAtoms);
this.alignment1 = new ArrayList<Integer>(cAlphaAtoms.length);
this.alignment2 = new ArrayList<Integer>(cAlphaAtoms.length);
for (int i = 0; i < cAlphaAtoms.length; i++) {
this.alignment1.add(i);
this.alignment2.add(i);
}
this.alignment2 = alignment1;
}

/**
Expand All @@ -41,43 +42,21 @@ public boolean isMatch(Atom[] caAlphaAtoms) {
return sequenceString.equals(getSequenceString(caAlphaAtoms));
}

public void addChain(Atom[] cAlphaAtoms, String chainId, int modelNumber, int structureId) {
this.caAtoms.add(cAlphaAtoms);
this.chainIds.add(chainId);
this.modelNumbers.add(modelNumber);
this.structureIds.add(structureId);
public String getChainId() {
return chainId;
}

public int getChainCount() {
return caAtoms.size();
}

public Atom[] getChain(int index) {
return caAtoms.get(index);
}

public String getChainId(int index) {
return chainIds.get(index);
}

public int getModelNumber(int index) {
return modelNumbers.get(index);
public int getModelNumber() {
return modelNumber;
}

public int getStructureId(int index) {
return structureIds.get(index);
public int getStructureId() {
return structureId;
}

public Atom[] getReferenceChain() {
return caAtoms.get(0);
public Atom[] getCalphaAtoms() {
return caAtoms;
}

/**
* @return the sequenceString
*/
public String getSequenceString() {
return sequenceString;
}

public String getSeqResSequence() {
return seqResSequence;
Expand Down Expand Up @@ -119,6 +98,7 @@ public static String getSequenceString(Atom[] caAlphaAtoms) {

for (Atom a: caAlphaAtoms) {
Group g = a.getGroup();
// TODO is the check for UNK required? UNK should have been filtered already in ChainClusterer?
if (! g.getPDBName().equals("UNK")) {
builder.append(g.getResidueNumber());
builder.append(g.getPDBName());
Expand All @@ -132,7 +112,7 @@ public static String getSequenceString(Atom[] caAlphaAtoms) {
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("#: ");
builder.append(caAtoms.size());
builder.append(caAtoms.length);
builder.append(" seq: ");
builder.append(sequenceString);
builder.append("\n");
Expand Down
Loading