JAL-4392 Merging consensus secondary structure
[jalview.git] / src / jalview / datamodel / Profile.java
index 8638896..35f1429 100644 (file)
@@ -32,6 +32,8 @@ public class Profile implements ProfileI
    * an object holding counts of symbols in the profile
    */
   private ResidueCount counts;
+  
+  private SecondaryStructureCount ssCounts;
 
   /*
    * the number of sequences (gapped or not) in the profile
@@ -47,12 +49,16 @@ public class Profile implements ProfileI
    * the highest count for any residue in the profile
    */
   private int maxCount;
+  private int maxSSCount;
+  
 
   /*
    * the residue (e.g. K) or residues (e.g. KQW) with the
    * highest count in the profile
    */
   private String modalResidue;
+  
+  private String modalSS;
 
   /**
    * Constructor which allows derived data to be stored without having to store
@@ -74,6 +80,14 @@ public class Profile implements ProfileI
     this.maxCount = max;
     this.modalResidue = modalRes;
   }
+  
+  public Profile(String modalSS, int ssCount, int gaps, int maxSSCount)
+  {
+    this.height = ssCount;
+    this.gapped = gaps;
+    this.maxSSCount = maxSSCount;
+    this.modalSS = modalSS;
+  }
 
   /* (non-Javadoc)
    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
@@ -83,6 +97,12 @@ public class Profile implements ProfileI
   {
     this.counts = residueCounts;
   }
+  
+  @Override
+  public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
+  {
+    this.ssCounts = secondaryStructureCount;
+  }
 
   /* (non-Javadoc)
    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
@@ -105,6 +125,25 @@ public class Profile implements ProfileI
     }
     return pid;
   }
+  
+  @Override
+  public float getSSPercentageIdentity(boolean ignoreGaps)
+  {
+    if (height == 0)
+    {
+      return 0f;
+    }
+    float ssPid = 0f;
+    if (ignoreGaps && gapped < height)
+    {
+      ssPid = (maxSSCount * 100f) / (height - gapped);
+    }
+    else
+    {
+      ssPid = (maxSSCount * 100f) / height;
+    }
+    return ssPid;
+  }
 
   /* (non-Javadoc)
    * @see jalview.datamodel.ProfileI#getCounts()
@@ -114,6 +153,12 @@ public class Profile implements ProfileI
   {
     return counts;
   }
+  
+  @Override
+  public SecondaryStructureCount getSSCounts()
+  {
+    return ssCounts;
+  }
 
   /* (non-Javadoc)
    * @see jalview.datamodel.ProfileI#getHeight()
@@ -141,6 +186,12 @@ public class Profile implements ProfileI
   {
     return maxCount;
   }
+  
+  @Override
+  public int getMaxSSCount()
+  {
+    return maxSSCount;
+  }
 
   /* (non-Javadoc)
    * @see jalview.datamodel.ProfileI#getModalResidue()
@@ -150,6 +201,12 @@ public class Profile implements ProfileI
   {
     return modalResidue;
   }
+  
+  @Override
+  public String getModalSS()
+  {
+    return modalSS;
+  }
 
   /* (non-Javadoc)
    * @see jalview.datamodel.ProfileI#getNonGapped()