Esempio n. 1
0
  /**
   * Returns the chemical property string for this chain in the 5 types system, but considers only
   * AA residues which are part of an SSE (ignores ligands and AAs in coiled regions).
   *
   * @param sseSeparator the String (most likely a single character) to add between two SSEs. You
   *     can specify the empty String if you do not want anything inserted, of course.
   * @return the chemical property string, 5 types system
   */
  public String[] getChainChemPropsStringSSEResiduesOnly(String sseSeparator) {
    StringBuilder sbChemProp = new StringBuilder();
    StringBuilder sbSSE = new StringBuilder();
    SSE s;
    String sseString = null;
    String sseStringlast = null;
    int numSeps = 0;

    // some basic stat stuff, just a quick test
    int numSSETypes = 2;
    int H = 0;
    int E = 1; // helix and strand
    int numResH = 0;
    int numResE = 0;
    Integer[][] chemPropsBySSEType = new Integer[numSSETypes][AminoAcid.ALL_CHEM_PROPS5.length];
    for (int i = 0; i < numSSETypes; i++) {
      Arrays.fill(chemPropsBySSEType[i], 0);
    }

    for (Residue r : this.residues) {
      if (r.isAA()) {
        s = r.getSSE();

        if (s != null) {
          if (s.isOtherSSE()) {
            continue;
          }
          sseString = s.getSSEClass();
          if (sseStringlast != null
              && (sseString == null ? sseStringlast != null : !sseString.equals(sseStringlast))) {
            sbChemProp.append(sseSeparator);
            sbSSE.append(sseSeparator);
            numSeps++;
          }
          sbChemProp.append(r.getChemicalProperty5OneLetterString());
          if (sseString.equals("H")) {
            numResH++;
            chemPropsBySSEType[H][r.getChemicalProperty5Type()]++;
          }
          if (sseString.equals("E")) {
            numResE++;
            chemPropsBySSEType[E][r.getChemicalProperty5Type()]++;
          }
          sbSSE.append(s.getSSEClass());
        }
        sseStringlast = sseString;
      }
    }

    // stat stuff
    Boolean doStats = false;
    if (doStats) {
      float[] sharesH = new float[AminoAcid.ALL_CHEM_PROPS5.length];
      float[] sharesE = new float[AminoAcid.ALL_CHEM_PROPS5.length];
      for (int i = 0; i < AminoAcid.ALL_CHEM_PROPS5.length; i++) {
        sharesH[i] = (float) numResH / (float) chemPropsBySSEType[H][i];
        sharesE[i] = (float) numResE / (float) chemPropsBySSEType[E][i];
      }
      System.out.println(
          "Chain: chemType by SSEtype[H]: totalH="
              + numResH
              + ", shares: "
              + IO.floatArrayToString(sharesH));
      System.out.println(
          "Chain: chemType by SSEtype[E]: totalE="
              + numResE
              + ", shares: "
              + IO.floatArrayToString(sharesE));
    }

    // System.out.println("Added " + numSeps + " separators.");
    return new String[] {sbChemProp.toString(), sbSSE.toString()};
  }
 /**
  * Change the value of a constraint
  *
  * @param c the integer representation of the constraint as defined in ConstraintParam
  * @param v whether the constraint should be enabled or disabled
  */
 public void put(int c, boolean v) {
   if (constraints.containsKey(c)) constraints.put(c, v);
   else IO.error("Warning: trying to add a constraint that has a undefined description. Ignored");
 }