001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.structure.symmetry.core; 022 023import org.biojava.nbio.structure.Structure; 024 025import java.util.Collections; 026import java.util.List; 027 028/** 029 * Clusters the chains of one or two structures by sequence. 030 */ 031public class ClusterProteinChains { 032 private Structure structure = null; 033 private Structure structure2 = null; 034 private QuatSymmetryParameters parameters = null; 035 private ClusterMerger merger = null; 036 private int proteinChainCount = 0; 037 private int nucleicAcidChainCount = 0; 038 039 public ClusterProteinChains(Structure structure, QuatSymmetryParameters parameters) { 040 this.structure = structure; 041 this.parameters = parameters; 042 run(); 043 } 044 045 public ClusterProteinChains(Structure structure1, Structure structure2, QuatSymmetryParameters parameters) { 046 this.structure = structure1; 047 this.structure2 = structure2; 048 this.parameters = parameters; 049 run(); 050 } 051 052 /** 053 * Get a non-redundent set of clusters for a given sequence cutoff 054 * @param sequenceIdentityThreshold 055 * @return 056 */ 057 public List<SequenceAlignmentCluster> getSequenceAlignmentClusters(double sequenceIdentityThreshold) { 058 if (merger == null) { 059 return Collections.emptyList(); 060 } 061 return merger.getMergedClusters(sequenceIdentityThreshold); 062 } 063 064 /** 065 * @return the proteinChainCount 066 */ 067 public int getProteinChainCount() { 068 return proteinChainCount; 069 } 070 071 /** 072 * @return the nucleicAcidChainCount 073 */ 074 public int getNucleicAcidChainCount() { 075 return nucleicAcidChainCount; 076 } 077 078 private void run () { 079 // cluster protein entities 080 List<SequenceAlignmentCluster> seqClusters = null; 081 082 if (structure2 == null) { 083 ProteinSequenceClusterer clusterer = new ProteinSequenceClusterer(structure, parameters); 084 seqClusters = clusterer.getSequenceAlignmentClusters(); 085 proteinChainCount = clusterer.getProteinChainCount(); 086 nucleicAcidChainCount = clusterer.getNucleicAcidChainCount(); 087 } else if (structure !=null && structure2 != null) { 088 ProteinSequenceClusterer clusterer = new ProteinSequenceClusterer(structure, structure2, parameters); 089 seqClusters = clusterer.getSequenceAlignmentClusters(); 090 } 091 if (seqClusters == null || seqClusters.size() == 0) { 092 return; 093 } 094 095 // calculate pairwise aligment between protein clusters 096 merger = new ClusterMerger(seqClusters, parameters); 097 merger.calcPairwiseAlignments(); 098 } 099}