Package com.mockturtlesolutions.snifflib.datatypes

Examples of com.mockturtlesolutions.snifflib.datatypes.DblMatrix


   
    if (descriptor.equals("parameter"))
    {
      //System.out.println("Adding parameter");
      pars = this.parameterGuesses;
      pars.setParam(parametername,new DblMatrix(0.0));
     
      pars = this.currentEstimates;
      pars.setParam(parametername,new DblMatrix(0.0));
     
     
    }
    else if (descriptor.equals("prior"))
    {
      //System.out.println("Adding prior");
      pars = this.priorParameters;
      pars.setParam(parametername,new DblMatrix(0.0));
     
    }
    else if (descriptor.equals("mixing"))
    {
      //System.out.println("Adding mixing "+ parametername);
      pars = this.mixingParameters;
      pars.setParam(parametername,new DblMatrix(0.0));
     
    }
    else if (descriptor.equals("configuration"))
    {
      //System.out.println("Adding configuration");
View Full Code Here


      pars = this.parameterGuesses;
      if (!pars.hasParameter(parametername))
      {
        throw new RuntimeException("Parameter "+parametername+" must be added before it can be set.");
      }
      pars.setParam(parametername,new DblMatrix(new Double(val)));
     
      pars = this.currentEstimates;
      if (!pars.hasParameter(parametername))
      {
        throw new RuntimeException("Parameter "+parametername+" must be added before it can be set.");
      }
      pars.setParam(parametername,new DblMatrix(new Double(val)));
      //System.out.println("Setting parameter:"+ parametername+" to "+val);
    }
   
    if (descriptor.equals("prior"))
    {
      pars = this.priorParameters;
      if (!pars.hasParameter(parametername))
      {
        throw new RuntimeException("Prior parameter "+parametername+" must be added before it can be set.");
      }
      pars.setParam(parametername,new DblMatrix(new Double(val)));
    }
   
    if (descriptor.equals("mixing"))
    {
      //System.out.println("Setting mixing parameter:"+ parametername);
      pars = this.mixingParameters;
      if (!pars.hasParameter(parametername))
      {
        throw new RuntimeException("Mixing parameter "+parametername+" must be added before it can be set.");
      }
      pars.setParam(parametername,new DblMatrix(new Double(val)));
      //System.out.println("Setting mixing parameter:"+ parametername+" to "+val);
    }
   
    if (descriptor.equals("configuration"))
    {
View Full Code Here

      pars = this.currentEstimates;
      params = pars.parameterSet();
   
      for (int j=0;j<params.length;j++)
      {
        DblMatrix val = pars.getParam(params[j]);
        outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
      }
    }
   
   
    if (descript.equals("prior"))
    {
   
      descriptor = "prior";
     
      pars = this.priorParameters;
      params = pars.parameterSet();
     
      for (int j=0;j<params.length;j++)
      {
        DblMatrix val = pars.getParam(params[j]);
        outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
      }
    }
   
    if (descript.equals("mixing"))
    {
   
      descriptor = "mixing";
      pars = this.mixingParameters;
      params = pars.parameterSet();

      for (int j=0;j<params.length;j++)
      {
        DblMatrix val = pars.getParam(params[j]);
        outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
      }
    }
   
    if (descript.equals("configuration"))
    {
View Full Code Here

      //System.out.println("There are no parameters.");
    //}
   
    for (int j=0;j<params.length;j++)
    {
      DblMatrix val = pars.getParam(params[j]);
      outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
    }
   
    descriptor = "prior";
    pars = this.priorParameters;
    params = pars.parameterSet();
   
    for (int j=0;j<params.length;j++)
    {
      DblMatrix val = pars.getParam(params[j]);
      outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
    }
   
    descriptor = "mixing";
    pars = this.mixingParameters;
    params = pars.parameterSet();
   
    for (int j=0;j<params.length;j++)
    {
      DblMatrix val = pars.getParam(params[j]);
      outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
    }
   
    descriptor = "configuration";
    HashMap configmap = this.configurationMap;
    Set pnames = configurationMap.keySet();
View Full Code Here

      {

        if (pname.startsWith("sigmaCb")) //Concentrations can not be negative!!
        {
          this.prop.setLogNormal(pname);
          this.prop.setMixingParam(pname,new DblMatrix(0.01));
        }
        else
        {
          this.prop.setLogNormal(pname);
          this.prop.setMixingParam(pname,new DblMatrix(0.001));
        }
      }
      else if (pname.startsWith("T#")) //Concentrations can not be negative!!
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.startsWith("TExpSSdev")) //Volume deviations can not be negative!!
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.startsWith("C#")) //
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.001));
      }
      else if (pname.startsWith("CExpdev")) //
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.startsWith("CExpSSdev")) //
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.startsWith("Vo#")) //Volumes added can not be negative!!
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.00001));
      }
      else if (pname.startsWith("v#")) //Volumes added can not be negative!!
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.contains("pKa#")) //From order-restricted inference on the pKa's
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.001));
      }
      else if (pname.contains("pKb#")) //From order-restricted inference on the pKa's
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.001));
      }
      else if (pname.contains("pKadiff")) //From order-restricted inference on the pKa's
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.contains("smoothingParameter"))
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.01));
      }
      else if (pname.contains("pKbdiff")) //From order-restricted inference on the pKb's
      {
        this.prop.setLogNormal(pname);
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.contains("interceptpH")) //Latent pH link parameter
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.contains("linearpH")) //Latent pH link parameter
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.contains("quadraticpH")) //Latent pH link parameter
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.0001));
      }
      else if (pname.contains("cubicpH")) //Latent pH link parameter.  Solution tends to be sensitive to this so take to be smaller than other link parameters.
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.00001));
      }
      else if (pname.contains("Cubic"))
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.000001));
      }
      else if (pname.contains("smoothing"))
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.00001));
      }
      else if (pname.contains("pH"))
      {
        this.prop.setMixingParam(pname,new DblMatrix(0.001));
      }
      else
      {
        DblMatrix VALUE = DblMatrix.abs(like.getParam(pname));
        if (DblMatrix.test(VALUE.eq(0.0)))
        {
          VALUE = new DblMatrix(0.000001);
        }
        else
        VALUE = VALUE.times(0.000001);
        }

        this.prop.setMixingParam(pname,VALUE);

      }
View Full Code Here

                {
                  showError("Only one selection allowed.")
                }
                else
                {
                  temperature = new DblMatrix(n);
                }
               
                if (okcancelListener != null)
                {
                  okcancelListener.actionPerformed(e);
View Full Code Here

    Vector pKaSet = new Vector();
    int ionStart=0;
    int ionStop=0;
    String ion;
    boolean readingIon=false;
    DblMatrix val;
    int k=0;
    while (k<pKa.length())
    {
      if (pKa.charAt(k)=='[')
      {
        if (readingIon)
        {
          throw new RuntimeException("Encountered extra '[' in buffer coefficients.")
        }
        readingIon = true;
        ionStart = k;
       
      }
      else
      {
        if (pKa.charAt(k)==']')
        {
          if (!readingIon)
          {
            throw new RuntimeException("Encountered extra ']' in buffer coefficients.")
          }
          ionStop = k+1;
          ion = pKa.substring(ionStart,ionStop);
          pKaSet.add(new DblMatrix(ion));
         
          readingIon = false;
        }
      }
      k++;
View Full Code Here

    Vector pKaSet = new Vector();
    int ionStart=0;
    int ionStop=0;
    String ion;
    boolean readingIon=false;
    DblMatrix val;
    int k=0;
    while (k<pKa.length())
    {
      if (pKa.charAt(k)=='[')
      {
        if (readingIon)
        {
          throw new RuntimeException("Encountered extra '[' in buffer coefficients.")
        }
        readingIon = true;
        ionStart = k;
       
      }
      else
      {
        if (pKa.charAt(k)==']')
        {
          if (!readingIon)
          {
            throw new RuntimeException("Encountered extra ']' in buffer coefficients.")
          }
          ionStop = k+1;
          ion = pKa.substring(ionStart,ionStop);
          pKaSet.add(new DblMatrix(ion));
         
          readingIon = false;
        }
      }
      k++;
View Full Code Here

    for (int m=0;m<comps.length;m++)
    {
      //System.out.println("???????????????????????????????????????????? Inside loop of addToComplexBuffer:"+comps[m]);
     
     
      DblMatrix tmp = cont_pred.getEstimatedConcentration(comps[m]);
      if (tmp == null)
      { 
        //System.out.println("The concentration is null for:"+comps[m]);
        cont_pred.setEstimatedConcentration(comps[m],conc);
        tmp = conc; 
      }
     
      //conc.show("conc");
      //cont_pred.getEstimatedConcentration(comps[m]).show("Other concentration:");
      cont_pred.setEstimatedConcentration(comps[m],conc.times(cont_pred.getEstimatedConcentration(comps[m])));
     
     
      if  (out.hasComponent(comps[m])) //The ComplexBufferPredictor already has an entry for this component...
      {
        //System.out.println("The ComplexBufferPredictor already has:"+comps[m]);
        DblMatrix weight1 = out.getEstimatedConcentration(comps[m]);
        DblMatrix weight2 = cont_pred.getEstimatedConcentration(comps[m]);
        DblMatrix new_conc = weight1.plus(weight2);

        DblMatrix[] pKa1 = out.getEstimatedpKa(comps[m]);
        DblMatrix[] pKa2 = cont_pred.getEstimatedpKa(comps[m]);
        DblMatrix[] new_pKa = new DblMatrix[pKa1.length];
       
        for (int n=0;n<pKa1.length;n++)
        {
          DblMatrix temp = weight1.times(pKa1[n]).plus(weight2.times(pKa2[n]));
          new_pKa[n] = temp.divideBy(weight1.plus(weight2));
          //new_pKa[n].show("new_pKa["+n+"]");
        }

        DblMatrix[] pKb1 = out.getEstimatedpKb(comps[m]);
        DblMatrix[] pKb2 = cont_pred.getEstimatedpKb(comps[m]);
        DblMatrix[] new_pKb = new DblMatrix[pKb1.length];

        for (int n=0;n<pKb1.length;n++)
        {
          DblMatrix temp = weight1.times(pKb1[n]).plus(weight2.times(pKb2[n]));
          new_pKb[n] = temp.divideBy(weight1.plus(weight2));
        }


        out.setEstimatedpKa(comps[m],new_pKa);
        out.setEstimatedpKb(comps[m],new_pKb);
View Full Code Here

      //
      newcomp.setName(bs.getNickname());
     
      //All top-level components should get assigned an initial concentration of 1.0.  This
      //jibes with the convention for complex buffers ("full strength" e.g. 1X ).
      newcomp.setConcentration(new DblMatrix(1.0));
     
      out.addComponent(bs.getNickname(),newcomp);
      Vector exps = bs.getExperimentNames();
     
      //Do some preliminary checking of the top level...
      boolean CONTAINED_SPECIFIED_AT_LEAST_ONCE = false;
      boolean COEFFICIENTS_SPECIFIED_AT_LEAST_ONCE = false;
      for (int i=0;i<exps.size();i++)
      {
        String exp = (String)exps.get(i);
        //System.out.println("Looking at exp:"+exp);
        if (CONTAINED_SPECIFIED_AT_LEAST_ONCE == false)
        {
          Vector csubs = bs.getContainedSubsampleIDs(exp);
          //System.out.println("Looking at subs:"+csubs.size());
          if (csubs.size() > 0) //bs has contained buffers.
          {
            CONTAINED_SPECIFIED_AT_LEAST_ONCE = true;
          }
        }
       
       
        if (COEFFICIENTS_SPECIFIED_AT_LEAST_ONCE == false)
        {                            
          Vector subsamples = bs.getBufferCoefficientsSubsampleIDs(exp);
          //System.out.println("Looking at bsubs:"+subsamples.size());
          if (subsamples.size() > 0)
          {
            COEFFICIENTS_SPECIFIED_AT_LEAST_ONCE = true;
          }
        }
      }
     
     
      if (COEFFICIENTS_SPECIFIED_AT_LEAST_ONCE && CONTAINED_SPECIFIED_AT_LEAST_ONCE)
      {
        throw new RuntimeException("Buffer support can not have both contained buffers and dissociation constants specified.  Please fix data.");
      }
   
      if (COEFFICIENTS_SPECIFIED_AT_LEAST_ONCE)
      {
        for (int i=0;i<exps.size();i++)
        {
          String exp = (String)exps.get(i);

          Vector subsamples = bs.getBufferCoefficientsSubsampleIDs(exp);
          for (int j=0;j<subsamples.size();j++) //There are buffer coefficients specified (e.g. as for a simple buffer like Malic acid)
          {

            HashMap avgpKa = AbstractSMPBuffer.getAveragepKa(bs);//This HashMap contains keys for pKa,pKb and SaltType
            //The fields are DblMatrix[].
            // Set keys = avgpKa.keySet();
//             Iterator iter = keys.iterator();
//             while (iter.hasNext())
//             {
//               System.out.println("KEY:"+iter.next());
//             }
           
           
            ComplexBufferComponent comp = out.getComponent(out.getName());
           
            if (comp == null)
            {
              throw new RuntimeException("The component "+out.getName()+" is null.");
            }
            DblMatrix[] tmp = (DblMatrix[])avgpKa.get("SaltType");
            //System.out.println("Lenght of tmp:"+tmp.length);
           
            if (tmp == null)
            {
              comp.setSaltType(null);
            }
            else
            {
              comp.setSaltType(tmp);
            }
            comp.setpKa((DblMatrix[])avgpKa.get("pKa"));
            comp.setpKb((DblMatrix[])avgpKa.get("pKb"));

          }
        }
      }
     
     
     
      if (CONTAINED_SPECIFIED_AT_LEAST_ONCE)
      {
        for (int i=0;i<exps.size();i++)
        {
          String exp = (String)exps.get(i);
          Vector csubs = bs.getContainedSubsampleIDs(exp);
       
          for (int j=0;j<csubs.size();j++)
          {
            String ssid = (String)csubs.get(j);
            Vector obsnums = bs.getContainedObservationNumbers(exp,ssid);

            for (int k=0;k<obsnums.size();k++)
            {
              String obs = (String)obsnums.get(j);
              String buffername = bs.getContainedNickname(exp,ssid,obs);
              String conc = bs.getContainedConcentration(exp,ssid,obs);

              BufferStorage cont_buff = (bs.getConnection()).getBuffer(repos,buffername);
             
             
              //THIS RECURSIVE CALL LEADS TO "FORWARDING" OF ANY SHARED CONTAINED COMPONENTS
              //WITHIN THE CONTAINED COMPLEX COMPONENTS OF THIS BUFFER.
              //
              //FOR EXAMPLE SUPPOSE THIS BUFFER CONTAINS BOTH LEMON JUICE AND CITRIC ACID
              //LEMON JUICE CONTAINS CITRIC ACID BUT THE PKA ARE ESTIMATED
              //DIFFERENT VALUES THAN FOR CITRIC ACID AS A PURE SOLUTION.  THE END VALUE FOR
              //CITRIC ACID IN THE SOLUTION WILL BE THE WEIGHTED AVERAGE OF ALL PKA/PKB
              //WHERE THE WEIGHTS ARE THE MOLAR CONCENTRATION OF EACH CONTRIBUTING SOURCE
              //COMPONENT IN THE FINAL SOLUTION.  SUPPOSE LEMON JUICE HAS 30mM CITRIC ACID AND
              //THE SOLUTION BEING CONSTRUCTED HAS 20mM PURE CITRIC ACID ALSO 0.5X LEMON JUICE
              //BEING ADDED.  THEN THE PKA FOR CITRIC ACID ARE CALCULATED AS
              //
              //            15*(PKA_LEMONJUICE) + 20*(PKA_PURECITRIC)/(35)
              //NOTE THAT THE FINAL CONCENTRATION OF CITRIC ACID WILL BE SAVED AS 35 MM AS WELL.
              //
             
              AbstractSMPBuffer.addToComplexBuffer(repos,out,cont_buff,new DblMatrix(conc),true);
            }
          }
        }
       
      }
View Full Code Here

TOP

Related Classes of com.mockturtlesolutions.snifflib.datatypes.DblMatrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.