package com.mockturtlesolutions.jpHtools.database;
//Copyright (C) 2005 Daniel P. Dougherty
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//$Id: AbstractSMPBuffer.java,v 1.6 2007/06/23 03:58:01 mock_turtle Exp $
import java.util.Vector;
import java.util.HashMap;
import java.util.Set;
import java.util.Iterator;
import com.mockturtlesolutions.snifflib.datatypes.DblMatrix;
import com.mockturtlesolutions.snifflib.datatypes.DblParamSet;
import java.lang.reflect.Method;
import com.mockturtlesolutions.snifflib.reposconfig.database.RepositoryListener;
import com.mockturtlesolutions.snifflib.reposconfig.database.RepositoryStorage;
/**
Semi-mechanistic partial buffer. This is the standard decorator class for the various buffer storage implementations. By default the underlying BufferStorage
class is a BufferDOM (XML DOM).
*/
public abstract class AbstractSMPBuffer implements BufferStorage
{
protected pHtoolsConnection connection;
protected Vector supportListeners;
protected Vector reposListeners;
public AbstractSMPBuffer()
{
this.supportListeners = new Vector();
}
// public void updateUsingParmeters(DblParamSet P)
// {
// DblParamSet out = new DblParamSet();
// ComplexBufferPredictor pred = this.getComplexPart();
//
// DblParamSet params = pred.getParams();
// String[] pnames = params.parameterSet();
//
// //
// //Overwrite the ComplexBufferPredictor's parameters
// //
// for (int j=0;j<pnames.length;j++)
// {
// if (P.hasParameter(pnames[j]))
// {
// params.setParam(pnames[j],P.getParam(pnames[j]));
// }
// }
//
// Vector obs;
// Vector subs;
// Vector exps = this.getExperimentNames();
// String expname;
// String ssid;
// String obsnum;
//
// for (int i=0;i<exps.size();i++)
// {
// expname = (String)exps.get(i);
// subs = this.getTitrationSubsampleIDs(expname);
// for (int j=0;j<subs.size();j++)
// {
// ssid = (String)subs.get(j);
// obs = this.getTitrationObservationNumbers(expname,ssid);
// for (int k=0;k<obs.size();k++)
// {
// obsnum = (String)obs.get(k);
//
// String param_name = expname+"_"+ssid+"_"+obsnum+"_pHi";
//
// if (P.hasParameter(param_name))
// {
// String pHi = P.getParam(param_name).getDoubleAt(0).toString();
// this.setpH(expname,ssid,obsnum,pHi);
// }
// }
// }
// }
// }
//
//
//
// public DblParamSet extractParameters()
// {
// ComplexBufferPredictor pred = this.getComplexPart();
//
// if (pred == null)
// {
// return(null);
// }
//
// //These are the non-nuissance parameters typically.
// DblParamSet params = pred.getParams().copy();
// Vector obs;
// Vector subs;
// Vector exps = this.getExperimentNames();
// String expname;
// String ssid;
// String obsnum;
//
// for (int i=0;i<exps.size();i++)
// {
// expname = (String)exps.get(i);
// subs = this.getTitrationSubsampleIDs(expname);
// for (int j=0;j<subs.size();j++)
// {
// ssid = (String)subs.get(j);
// obs = this.getTitrationObservationNumbers(expname,ssid);
// for (int k=0;k<obs.size();k++)
// {
// obsnum = (String)obs.get(k);
// String pHi = this.getpH(expname,ssid,obsnum);
//
// String param_name = expname+"_"+ssid+"_"+obsnum+"_pHi";
// params.setParam(param_name,new DblMatrix(pHi));
// }
// }
// }
//
// return(params);
// }
public void addBufferListener(BufferListener lr)
{
this.supportListeners.add(lr);
}
public void removeBufferListener(BufferListener lr)
{
this.supportListeners.remove(lr);
}
public void addRepositoryListener(RepositoryListener lr)
{
this.reposListeners.add(lr);
}
public void removeRepositoryListener(RepositoryListener lr)
{
this.reposListeners.remove(lr);
}
public void fireBufferSupportRemoved(String expname)
{
BufferEvent ev = new BufferEvent(BufferEvent.SUPPORT_REMOVED,null,expname);
for (int j=0;j<this.supportListeners.size();j++)
{
((BufferListener)this.supportListeners).bufferActionPerformed(ev);
}
}
public void fireBufferSupportAdded(String expname)
{
BufferEvent ev = new BufferEvent(BufferEvent.SUPPORT_ADDED,null,expname);
for (int j=0;j<this.supportListeners.size();j++)
{
((BufferListener)this.supportListeners.get(j)).bufferActionPerformed(ev);
}
}
public void setConnection(pHtoolsConnection conn)
{
this.connection = conn;
}
public pHtoolsConnection getConnection()
{
return(this.connection);
}
/**
Return an array containing the SaltType of each ion.
*/
public static DblMatrix[] parseSaltType(String pKa)
{
pKa = pKa.trim();//Remove leading an trailing whitespace.
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++;
}
DblMatrix[] out = new DblMatrix[pKaSet.size()];
for (int j=0;j<pKaSet.size();j++)
{
out[j] = (DblMatrix)pKaSet.get(j);
}
return(out);
}
/**
Return an array containing the Ka of each ion.
*/
public static DblMatrix[] parsepK(String pKa)
{
pKa = pKa.trim();//Remove leading an trailing whitespace.
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++;
}
DblMatrix[] out = new DblMatrix[pKaSet.size()];
for (int j=0;j<pKaSet.size();j++)
{
out[j] = (DblMatrix)pKaSet.get(j);
}
return(out);
}
/**
Get vectors of pKa and pKb averaged over all experiments and subsamples.
This method averages first within an experiment (averaging over the subsamples) then averages the subsample
means over the experiments. Note: If a particular experiment does not have any subsamples for dissociation constants
then it is not included in the averaging process.
*/
public static HashMap getAveragepKa(BufferStorage buffer)
{
DblMatrix[] pKa = null;
DblMatrix[] pKb = null;
DblMatrix[] SaltType = null;
DblMatrix[] temp = null;
int Nsubtot = 0;
int Nexptot = 0;
Vector exps,ssids;
String expname,ssid;
exps = buffer.getExperimentNames();
for (int j=0;j<exps.size();j++) //For each experiment...
{
expname = (String)exps.get(j);
ssids = buffer.getBufferCoefficientsSubsampleIDs(expname);
Nsubtot = 0;
for (int k=0;k<ssids.size();k++) //For each subsample...
{
ssid = (String)ssids.get(k);
temp = AbstractSMPBuffer.parsepK(buffer.getpKa(expname,ssid));
if (pKa == null)
{
pKa = temp;
}
else
{
if (temp.length != pKa.length)
{
throw new RuntimeException("Number of dissociable ions are unequal within buffer.");
}
//Gather sum of Ka!! We turn into average later.
for (int l=0;l<pKa.length;l++)
{
pKa[l] = pKa[l].plus(temp[l]);
}
}
//System.out.println("8888888888888888888888888888888888888888888888888888888888888888888");
temp = AbstractSMPBuffer.parsepK(buffer.getpKb(expname,ssid));
if (pKb == null)
{
pKb = temp;
}
else
{
if (temp.length != pKb.length)
{
throw new RuntimeException("Number of dissociable ions are unequal within buffer.");
}
//Gather sum of Kb!! We turn into average later.
for (int l=0;l<pKb.length;l++)
{
pKb[l] = pKb[l].plus(temp[l]);
}
}
temp = AbstractSMPBuffer.parseSaltType(buffer.getSaltType(expname,ssid));
if (SaltType == null)
{
SaltType = temp;
}
else
{
if (temp.length != SaltType.length)
{
throw new RuntimeException("Number of dissociable ions are unequal within buffer.");
}
//Gather sum of Kb!! We turn into average later.
for (int l=0;l<SaltType.length;l++)
{
SaltType[l] = SaltType[l].plus(temp[l]);
}
}
Nsubtot++;
}
//Calculate the average within each experiment (over the subsamples)!
if (pKa != null)
{
if (pKa.length != pKb.length)
{
throw new IllegalArgumentException("Different number of ions represented in Ka and Kb.");
}
if (pKa.length != SaltType.length)
{
throw new IllegalArgumentException("Different number of ions represented in Ka and Kb.");
}
//Calculate average Ka's for each dissociable ion over the subsamples.
//Is it better to average Ka's or pKa's???
for (int l=0;l<pKa.length;l++)
{
pKa[l] = pKa[l].divideBy(Nsubtot);
pKb[l] = pKb[l].divideBy(Nsubtot);
SaltType[l] = SaltType[l].divideBy(Nsubtot);
}
}
Nexptot++;
}
//System.out.println("8888888888888888888888888888888888888888888888888888888888888888888");
HashMap OUT = null;
//Calculate the average over the experiments (using the averages within subsample as the data)!
if (pKa != null)
{
if (pKa.length != pKb.length)
{
throw new IllegalArgumentException("Different number of ions represented in Ka and Kb.");
}
if (pKa.length != SaltType.length)
{
throw new IllegalArgumentException("Different number of ions represented in Ka and Kb.");
}
//Calculate average Ka's for each dissociable ion over the subsamples.
//Is it better to average Ka's or pKa's???
for (int l=0;l<pKa.length;l++)
{
pKa[l] = pKa[l].divideBy(Nexptot);
pKb[l] = pKb[l].divideBy(Nexptot);
SaltType[l] = SaltType[l].divideBy(Nexptot);
}
OUT = new HashMap();
OUT.put("pKa",pKa);
OUT.put("pKb",pKb);
OUT.put("SaltType",SaltType);
}
//System.out.println("Done getting averaged Ka");
return(OUT);
}
/**
Gets the initial complex buffer part for the BufferStorage. If this SMPB model had not been estimated
before for this bufferstorage then it will not have a complex part. A default complex part will be
estimated by
i) Taking weighted averages of pKa and pKb using molar concentrations as the weights of contained
simple components (the reasoning being is that those might be reasonable first guesses for the pKa/pKb
in the new experimental environment).
ii) Any smoothing components for contained buffers that have pKa and pKb will be discarded (the reasoning
is that such smoothing will be estimated for the input buffer storage as a whole via SMPB fitting anyway and
we want the new best estimates for the pKa/pKb -- keeping the old smoothing in there will likely lead
to bias since the smoothing for such components is convolved tightly with the pKa/pKb).
iii) Any purely complex component (no pKa/pKb given -- but possible smoothing and/or contained buffers listed)
will have it's smoothing component retained as is (this may be poor approximation if pKa/pKb of the complex
buffer component do change under the new environment). This is the fundamental tenet of pHtools -- a complex
buffer can be well modeled by adding the contributions from a few key components to a
smoothed approximation of the contributions from a (possibly) large number of unknowns. When this turns out to
be a poor approximation (as can be judged by validating against a buffer system where those key components
are perturbed) the researcher **must** identify and model more specific components within the complex. Using
HPLC for example to determine the identity of predominant weak acids or bases. Such situations do not indicate a
failure of the SMPB approach but highlight exactly the role the SMPB approach can take in obtaining satisfactory
models of complex buffer systems in the context of research or health and safety regulation or in rational product
design. There are caveates to this idea however. In particular SMPB should never be expected to perform well
for buffers with very little buffer capacity (de-ionized water being the canonical example) or in situations where
the soluability limits of buffer compoents are being approached. Note however that SMPB can be used in the context of
a dynamic simulation where precipitation or other reactionsare modeled concurrently with the buffer dynamics.
Note: If you want to get the initial complex buffer predictor for a BufferStorage that **already** has
a ComplexPart associated at the top level then consider calling the method with the boolean ignore top-level switch
input as true. Otherwise it is wasteful to call with true (i.e. duplication of effort).
*/
public static ComplexBufferPredictor getInitialComplexBufferPredictor(String repos,BufferStorage bs)
{
//Calling with the ignore flag set to false is the default. This leads to the current complex buffer
//part being returned "as is" rather than calculating from the supporting data.
return(AbstractSMPBuffer.getInitialComplexBufferPredictor(repos,bs,false));
}
/**
Adds the buffer storage at the given molar concentration to the ComplexBufferPredictor.
If the boolean flag is false then the smoothing components of contained components in the BufferStorage
being added will not be dropped.
*/
public static void addToComplexBuffer(String repos,ComplexBufferPredictor out,BufferStorage cont_buff,DblMatrix conc,boolean dropsmooth)
{
ComplexBufferPredictor cont_pred = AbstractSMPBuffer.getInitialComplexBufferPredictor(repos,cont_buff);
String[] comps = cont_pred.getComponents();
//System.out.println("????????????????????????????????????????????");
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);
out.setEstimatedConcentration(comps[m],new_conc);
// ComplexBufferComponent comp = out.getComponent(comps[m]);
// comp.setEstimatedpKa(new_pKa);
// comp.setEstimatedpKb(new_pKb);
// comp.setConcentration(new_conc);
//Ok that updates out's component -- done!
}
else //First time encountering this sub-component -- need to add it.
{
//System.out.println("First time encountering this sub-component:"+comps[m]);
// /////Just check something here...
// ComplexBufferPredictor fuck = out;
//
// if (fuck.hasComponent("com.mockturtlesolutions.water"))
// {
// HashMap badKaMap = fuck.getEstimatedKa("com.mockturtlesolutions.water");
//
// DblMatrix[] badkA = (DblMatrix[])badKaMap.get("Ka");
// badkA[0].show("Sense2","0.00E0");
// // if (true)
// // {
// // throw new RuntimeException("Problem");
// // }
// }
// //////
out.addComponent(comps[m],cont_pred.getComponent(comps[m]));
//Recall cont_pred was updated before the current IF-Block.
out.setEstimatedConcentration(comps[m],cont_pred.getEstimatedConcentration(comps[m]));
//out.setEstimatedConcentration(comps[m],conc.times(cont_pred.getEstimatedConcentration(comps[m])));
}
//System.out.println("???????????????????????????????????????????? Finished loop.");
}
}
/**
Gets the initial complex buffer part for the BufferStorage. If the boolean input is set to true then a pre-existing complex
part fo the buffer storage will be ignored.
*/
public static ComplexBufferPredictor getInitialComplexBufferPredictor(String repos,BufferStorage bs,boolean ignore_top_level)
{
//We need to traverse the nested structure of any contained buffers so, yes, we need the repository
//we are using.
ComplexBufferPredictor out = new ComplexBufferPredictor();
out.setName(bs.getNickname());
//System.out.println("ABSTRACTSMPBUFFER processing buffer:"+bs.getNickname());
//It is possible that there are no experiments and only a ComplexBufferPredictor associated with this buffer
//although that would be strange.
// ComplexBufferPredictor cmplx = bs.getComplexPart();
//
// if ((cmplx != null) && (!ignore_top_level)) //Not ignoring top level and there is already a complex buffer there at the top level!
// {
// System.out.println("Not ignoring top level and there is already a complex buffer there at the top level!");
//
// out = cmplx; //That's it -- you are done!
// }
// else
// {
//Wait the nickname could be empty in SMPBFrame for example!!
ComplexBufferComponent newcomp = new ComplexBufferComponent();
//If the buffer storage has buffer coefficients specified at the top level then
//
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);
}
}
}
}
//}
return(out);
}
/**
Returns true if any experiments supporting this buffer have titration data.
*/
public boolean hasTitrationData()
{
Vector Exps = this.getExperimentNames();
Vector tssids;
boolean anexperimenthastitration = false;
for (int m=0;m<Exps.size();m++)
{
int k=0;
String AExp = (String)Exps.get(m);
tssids = this.getTitrationSubsampleIDs(AExp);
if (tssids.size() >0 )
{
anexperimenthastitration = true;
break;
}
}
return(anexperimenthastitration);
}
/**
Calculate a checksum over the supporting information of this buffer.
*/
public String calculateCheckSum()
{
long checksum = 0;
checksum += Long.parseLong(this.getEnabled());
checksum += Long.parseLong(this.getNickname());
checksum += Long.parseLong(this.getStandardName());
checksum += Long.parseLong(this.getCreatedBy());
checksum += Long.parseLong(this.getCreatedOn());
checksum += Long.parseLong(this.getComment());
//ComplexBufferPredictor cpred = this.getComplexPart();
//checksum += Long.parseLong(cpred.getName());
// String[] names = cpred.getComponents();
// for (int j=0;j<names.length;j++)
// {
// ComplexBufferComponent comp = cpred.getComponent(names[j]);
//
// checksum += Long.parseLong(comp.getName());
// DblMatrix[] pKa = comp.getpKa();
// DblMatrix[] pKb = comp.getpKb();
// DblMatrix[] SaltType = comp.getSaltType();
// for (int m=0;m<SaltType.length;m++)
// {
// checksum += Long.parseLong(pKa[m].toString());
// checksum += Long.parseLong(pKb[m].toString());
// checksum += Long.parseLong(SaltType[m].toString());
// }
// }
//checksum += Long.parseLong(this.getComplexPart()); //We include the complex part in the checksum.
Vector Exps = this.getExperimentNames();
Vector Expsdelete;
Vector SS,SSdelete,NN,NNdelete;
String Exp,concentration,val,ssid,tid;
boolean altered;
if (Exps.size()!=0)
{
for (int j=0;j<Exps.size();j++)
{
Exp = (String)Exps.get(j);
checksum += Long.parseLong(Exp);
checksum += Long.parseLong(this.getExperimentEnabled(Exp));
checksum += Long.parseLong(this.getDescription(Exp));
checksum += Long.parseLong(this.getPerformedBy(Exp));
checksum += Long.parseLong(this.getPerformedOn(Exp));
//Add the subsample measurements of "static" buffer coefficients (pKa,pKb etc).
SS = this.getBufferCoefficientsSubsampleIDs(Exp);
SSdelete = this.getBufferCoefficientsSubsampleIDs(Exp);
if (SS.size()>0)
{
for (int k=0;k<SS.size();k++)
{
ssid = (String)SS.get(k);
checksum += Long.parseLong(ssid);
checksum += Long.parseLong(this.getpKa(Exp,ssid));
checksum += Long.parseLong(this.getpKb(Exp,ssid));
checksum += Long.parseLong(this.getSaltType(Exp,ssid));
}
}
//Add the subsample measurements of contained buffers.
SS = this.getContainedSubsampleIDs(Exp);
SSdelete = this.getContainedSubsampleIDs(Exp);
if (SS.size()>0)
{
for (int k=0;k<SS.size();k++)
{
ssid = (String)SS.get(k);
checksum += Long.parseLong(ssid);
NN = this.getContainedObservationNumbers(Exp,ssid);
NNdelete = this.getContainedObservationNumbers(Exp,ssid);
for (int l=0;l<NN.size();l++)
{
tid = (String)NN.get(l);
checksum += Long.parseLong(tid);
if ((tid == null) || (tid.equals("")))
{
throw new RuntimeException("Observation number can not be empty.");
}
val = this.getContainedNickname(Exp,ssid,tid);
checksum += Long.parseLong(val);
val = this.getContainedConcentration(Exp,ssid,tid);
checksum += Long.parseLong(val);
}
}
}
///////////////////////////////////////////
//Add the titration measurements of contained buffers.
SS = this.getTitrationSubsampleIDs(Exp);
//System.out.println("This is the experiment"+Exp);
//System.out.println("This is the number of SS"+SS.size());
SSdelete = this.getTitrationSubsampleIDs(Exp);
if (SS.size()>0)
{
for (int k=0;k<SS.size();k++)
{
ssid = (String)SS.get(k);
checksum += Long.parseLong(ssid);
checksum += Long.parseLong(this.getTemperature(Exp,ssid));
checksum += Long.parseLong(this.getDielectric(Exp,ssid));
checksum += Long.parseLong(this.getpHProbe(Exp,ssid));
NN = this.getTitrationObservationNumbers(Exp,ssid);
NNdelete = this.getTitrationObservationNumbers(Exp,ssid);
for (int l=0;l<NN.size();l++)
{
tid = (String)NN.get(l);
checksum += Long.parseLong(tid);
if (tid == null)
{
throw new RuntimeException("Titration observation number can not be null.");
}
val = this.getTitrant(Exp,ssid,tid);
checksum += Long.parseLong(val);
val = this.getTitrantConcentration(Exp,ssid,tid);
checksum += Long.parseLong(val);
val = this.getVolumeAdded(Exp,ssid,tid);
checksum += Long.parseLong(val);
val = this.getpH(Exp,ssid,tid);
checksum += Long.parseLong(val);
val = this.getRemark(Exp,ssid,tid);
checksum += Long.parseLong(val);
}
}
}
}
}
Long outl = new Long(checksum);
return(outl.toString());
}
// public void transferStorage(BufferStorage that,String Exp)
// {
// Vector Expsdelete = this.getExperimentNames();
// Vector SS,SSdelete,NN,NNdelete;
// String concentration,val,ssid,tid;
// boolean altered;
//
// if (!Expsdelete.contains(Exp))
// {
// //System.out.println("Adding the experiment:"+Exp);
// this.addExperiment(Exp);
// }
//
// //System.out.println("What went wrong?!!!!!!!!!!");
// //System.out.println("->"+Exp);
// //System.out.println("->"+that);
//
// this.setExperimentEnabled(Exp,that.getExperimentEnabled(Exp));
//
// //System.out.println("Here is description in"+Exp);
// this.setDescription(Exp,that.getDescription(Exp));
// this.setPerformedBy(Exp,that.getPerformedBy(Exp));
// this.setPerformedOn(Exp,that.getPerformedOn(Exp));
//
// //Add the subsample measurements of "static" buffer coefficients (pKa,pKb etc).
// SS = that.getBufferCoefficientsSubsampleIDs(Exp);
//
// SSdelete = this.getBufferCoefficientsSubsampleIDs(Exp);
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
// //System.out.println("Showing ssid:"+ssid);
// if (!SSdelete.contains(ssid))
// {
// this.addBufferCoefficientsSubsample(Exp,ssid);
// }
// //System.out.println("Setting pKa Here----"+ssid);
// this.setpKa(Exp,ssid,that.getpKa(Exp,ssid));
// this.setpKb(Exp,ssid,that.getpKb(Exp,ssid));
// this.setSaltType(Exp,ssid,that.getSaltType(Exp,ssid));
//
// }
// }
//
// //Remove those BufferCoefficientSubsamples not in "that" experiment.
// //SSdelete = this.getBufferCoefficientsSubsampleIDs();
// altered = SSdelete.removeAll(SS);
// if (SSdelete.size()>0)
// {
// for (int k=0;k<SSdelete.size();k++)
// {
// ssid = (String)SSdelete.get(k);
// //System.out.println("Removing BufferCoefficientsSubsample:"+ssid);
// this.removeBufferCoefficientsSubsample(Exp,ssid);
// }
// }
//
// ///////////////////////////////////////////
//
// //Add the subsample measurements of contained buffers.
// SS = that.getContainedSubsampleIDs(Exp);
// SSdelete = this.getContainedSubsampleIDs(Exp);
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
//
// if (!SSdelete.contains(ssid))
// {
//
// this.addContainedSubsample(Exp,ssid);
// }
//
// NN = that.getContainedObservationNumbers(Exp,ssid);
// NNdelete = this.getContainedObservationNumbers(Exp,ssid);
//
// for (int l=0;l<NN.size();l++)
// {
// tid = (String)NN.get(l);
//
// if ((tid == null) || (tid.equals("")))
// {
// throw new RuntimeException("Observation number can not be empty.");
// }
//
// if (!NNdelete.contains(tid))
// {
//
// this.addContainedObservation(Exp,ssid,tid);
// }
//
// val = that.getContainedNickname(Exp,ssid,tid);
// this.setContainedNickname(Exp,ssid,tid,val);
//
// val = that.getContainedConcentration(Exp,ssid,tid);
// this.setContainedConcentration(Exp,ssid,tid,val);
// }
//
// ///Remove any observations not in the new data.
// //NNdelete = this.getContainedObservationNumbers(ssid);
// altered = NNdelete.removeAll(NN);
// if (NNdelete.size()>0)
// {
// for (int m=0;m<NNdelete.size();m++)
// {
// tid = (String)NNdelete.get(m);
// this.removeContainedObservation(Exp,ssid,tid);
// }
// }
// }
// }
//
// //Remove those ContainedSubsamples not in "that" experiment.
// //SSdelete = this.getContainedSubsampleIDs();
// altered = SSdelete.removeAll(SS);
// if (SSdelete.size()>0)
// {
// for (int k=0;k<SSdelete.size();k++)
// {
// ssid = (String)SSdelete.get(k);
// this.removeContainedSubsample(Exp,ssid);
// }
// }
//
//
// ///////////////////////////////////////////
//
// //Add the titration measurements of contained buffers.
//
// SS = that.getTitrationSubsampleIDs(Exp);
// //System.out.println("This is the experiment"+Exp);
// //System.out.println("This is the number of SS"+SS.size());
//
// SSdelete = this.getTitrationSubsampleIDs(Exp);
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
// //System.out.println("ssid="+ssid);
// if (!SSdelete.contains(ssid))
// {
// this.addTitrationSubsample(Exp,ssid);
// }
// this.setInitialVolume(Exp,ssid,that.getInitialVolume(Exp,ssid));
// this.setTemperature(Exp,ssid,that.getTemperature(Exp,ssid));
// this.setDielectric(Exp,ssid,that.getDielectric(Exp,ssid));
// this.setpHProbe(Exp,ssid,that.getpHProbe(Exp,ssid));
// NN = that.getTitrationObservationNumbers(Exp,ssid);
// NNdelete = this.getTitrationObservationNumbers(Exp,ssid);
// for (int l=0;l<NN.size();l++)
// {
// tid = (String)NN.get(l);
// if (tid == null)
// {
// throw new RuntimeException("Titration observation number can not be null.");
// }
// if (!NNdelete.contains(tid))
// {
// this.addTitrationPoint(Exp,ssid,tid);
// }
//
// val = that.getTitrant(Exp,ssid,tid);
// this.setTitrant(Exp,ssid,tid,val);
//
// val = that.getTitrantConcentration(Exp,ssid,tid);
// this.setTitrantConcentration(Exp,ssid,tid,val);
//
// val = that.getVolumeAdded(Exp,ssid,tid);
// this.setVolumeAdded(Exp,ssid,tid,val);
//
// val = that.getpH(Exp,ssid,tid);
// this.setpH(Exp,ssid,tid,val);
//
// val = that.getRemark(Exp,ssid,tid);
// this.setRemark(Exp,ssid,tid,val);
// }
//
// //NNdelete = this.getTitrationObservationNumbers(ssid);
// altered = NNdelete.removeAll(NN);
// if (NNdelete.size()>0)
// {
// for (int m=0;m<NNdelete.size();m++)
// {
// tid = (String)NNdelete.get(m);
// this.removeTitrationPoint(Exp,ssid,tid);
// }
// }
// }
// }
//
// //Remove those TitrationSubsamples not in "that" experiment.
// //SSdelete = this.getTitrationSubsampleIDs();
// altered = SSdelete.removeAll(SS);
// if (SSdelete.size()>0)
// {
// for (int k=0;k<SSdelete.size();k++)
// {
// ssid = (String)SSdelete.get(k);
// this.removeTitrationSubsample(Exp,ssid);
// }
// }
// }
public void transferStorage(BufferStorage that,String Exp)
{
this.transferAgent.transferStorage(BufferStorage that,String Exp);
}
// public void transferStorage(BufferStorage that,String Exp)
// {
// Vector Expsdelete = this.getExperimentNames();
// Vector SS,SSdelete,NN,NNdelete;
// String concentration,val,ssid,tid;
// boolean altered;
//
// if (!Expsdelete.contains(Exp))
// {
// //System.out.println("Adding the experiment:"+Exp);
// this.addExperiment(Exp);
// }
//
// //System.out.println("What went wrong?!!!!!!!!!!");
// //System.out.println("->"+Exp);
// //System.out.println("->"+that);
//
// this.setExperimentEnabled(Exp,that.getExperimentEnabled(Exp));
//
// //System.out.println("Here is description in"+Exp);
// this.setDescription(Exp,that.getDescription(Exp));
// this.setPerformedBy(Exp,that.getPerformedBy(Exp));
// this.setPerformedOn(Exp,that.getPerformedOn(Exp));
//
// //Add the subsample measurements of "static" buffer coefficients (pKa,pKb etc).
// SS = that.getBufferCoefficientsSubsampleIDs(Exp);
//
// SSdelete = this.getBufferCoefficientsSubsampleIDs(Exp);
//
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
// if (!SSdelete.contains(ssid))
// {
// this.addBufferCoefficientsSubsample(Exp,ssid);
// }
// }
// }
//
// //Remove those BufferCoefficientSubsamples not in "that" experiment.
// //SSdelete = this.getBufferCoefficientsSubsampleIDs();
// altered = SSdelete.removeAll(SS);
// if (SSdelete.size()>0)
// {
// for (int k=0;k<SSdelete.size();k++)
// {
// ssid = (String)SSdelete.get(k);
// //System.out.println("Removing BufferCoefficientsSubsample:"+ssid);
// this.removeBufferCoefficientsSubsample(Exp,ssid);
// }
// }
//
//
//
// if (SS.size()>0)
// {
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOn();
// }
//
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
//
// //System.out.println("Setting pKa Here----"+ssid);
// if (this instanceof SetsBufferCoefficientsRow)
// {
// ((SetsBufferCoefficientsRow)this).setBufferCoefficientsRow(Exp,ssid,that.getpKa(Exp,ssid),that.getpKb(Exp,ssid),that.getSaltType(Exp,ssid));
//
// }
// else
// {
// this.setpKa(Exp,ssid,that.getpKa(Exp,ssid));
// this.setpKb(Exp,ssid,that.getpKb(Exp,ssid));
// this.setSaltType(Exp,ssid,that.getSaltType(Exp,ssid));
// }
//
// }
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOff();
// }
// }
//
//
//
// ///////////////////////////////////////////
//
// //Add the subsample measurements of contained buffers.
// SS = that.getContainedSubsampleIDs(Exp);
// SSdelete = this.getContainedSubsampleIDs(Exp);
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
// if (!SSdelete.contains(ssid))
// {
//
// this.addContainedSubsample(Exp,ssid);
// }
// }
//
// }
//
// //Remove those ContainedSubsamples not in "that" experiment.
// //SSdelete = this.getContainedSubsampleIDs();
// altered = SSdelete.removeAll(SS);
// if (SSdelete.size()>0)
// {
// for (int k=0;k<SSdelete.size();k++)
// {
// ssid = (String)SSdelete.get(k);
// this.removeContainedSubsample(Exp,ssid);
// }
// }
//
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
//
// NN = that.getContainedObservationNumbers(Exp,ssid);
// NNdelete = this.getContainedObservationNumbers(Exp,ssid);
//
// for (int l=0;l<NN.size();l++)
// {
// tid = (String)NN.get(l);
// if ((tid == null) || (tid.equals("")))
// {
// throw new RuntimeException("Observation number can not be empty.");
// }
//
// if (!NNdelete.contains(tid))
// {
//
// this.addContainedObservation(Exp,ssid,tid);
// }
// }
//
// altered = NNdelete.removeAll(NN);
// if (NNdelete.size()>0)
// {
// for (int m=0;m<NNdelete.size();m++)
// {
// tid = (String)NNdelete.get(m);
// this.removeContainedObservation(Exp,ssid,tid);
// }
// }
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOn();
// }
//
// for (int l=0;l<NN.size();l++)
// {
// tid = (String)NN.get(l);
//
// if ((tid == null) || (tid.equals("")))
// {
// throw new RuntimeException("Observation number can not be empty.");
// }
//
//
// if (this instanceof SetsContainedRow)
// {
//
// ((SetsContainedRow)this).setContainedRow(Exp,ssid,tid,that.getContainedNickname(Exp,ssid,tid),that.getContainedConcentration(Exp,ssid,tid));
//
// }
// else
// {
// val = that.getContainedNickname(Exp,ssid,tid);
// this.setContainedNickname(Exp,ssid,tid,val);
//
// val = that.getContainedConcentration(Exp,ssid,tid);
// this.setContainedConcentration(Exp,ssid,tid,val);
// }
//
//
// }
//
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOff();
// }
//
// ///Remove any observations not in the new data.
// //NNdelete = this.getContainedObservationNumbers(ssid);
//
// }
// }
//
//
//
//
// ///////////////////////////////////////////
//
// //Add the titration measurements of contained buffers.
//
// SS = that.getTitrationSubsampleIDs(Exp);
// //System.out.println("This is the experiment"+Exp);
// //System.out.println("This is the number of SS"+SS.size());
//
// SSdelete = this.getTitrationSubsampleIDs(Exp);
//
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
// //System.out.println("ssid="+ssid);
// if (!SSdelete.contains(ssid))
// {
// this.addTitrationSubsample(Exp,ssid);
// }
// }
// }
//
// //Remove those TitrationSubsamples not in "that" experiment.
// //SSdelete = this.getTitrationSubsampleIDs();
// altered = SSdelete.removeAll(SS);
// if (SSdelete.size()>0)
// {
// for (int k=0;k<SSdelete.size();k++)
// {
// ssid = (String)SSdelete.get(k);
// this.removeTitrationSubsample(Exp,ssid);
// }
// }
//
// if (SS.size()>0)
// {
// for (int k=0;k<SS.size();k++)
// {
// ssid = (String)SS.get(k);
// //System.out.println("ssid="+ssid);
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOn();
// }
//
// this.setInitialVolume(Exp,ssid,that.getInitialVolume(Exp,ssid));
// this.setTemperature(Exp,ssid,that.getTemperature(Exp,ssid));
// this.setDielectric(Exp,ssid,that.getDielectric(Exp,ssid));
// this.setpHProbe(Exp,ssid,that.getpHProbe(Exp,ssid));
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOff();
// }
//
// NN = that.getTitrationObservationNumbers(Exp,ssid);
// NNdelete = this.getTitrationObservationNumbers(Exp,ssid);
// for (int l=0;l<NN.size();l++)
// {
// tid = (String)NN.get(l);
// if (tid == null)
// {
// throw new RuntimeException("Titration observation number can not be null.");
// }
//
// if (!NNdelete.contains(tid))
// {
// this.addTitrationPoint(Exp,ssid,tid);
// }
// }
//
// //NNdelete = this.getTitrationObservationNumbers(ssid);
// altered = NNdelete.removeAll(NN);
// if (NNdelete.size()>0)
// {
// for (int m=0;m<NNdelete.size();m++)
// {
// tid = (String)NNdelete.get(m);
// this.removeTitrationPoint(Exp,ssid,tid);
// }
// }
//
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOn();
// }
//
// if (that instanceof BatchGetting)
// {
// ((BatchGetting)that).setBatchGettingOn();
// ((BatchGetting)that).getBatchTitrationPoints(Exp,ssid);
// }
//
// for (int l=0;l<NN.size();l++)
// {
//
// tid = (String)NN.get(l);
// if (tid == null)
// {
// throw new RuntimeException("Titration observation number can not be null.");
// }
// //System.out.println("Setting titration table row:"+l);
//
//
// if (this instanceof SetsTitrationRow)
// {
// //System.out.println("Setting titration table row using SetsTitrationRow:"+l);
// ((SetsTitrationRow)this).setTitrationRow(Exp,ssid,tid,that.getTitrant(Exp,ssid,tid),that.getTitrantConcentration(Exp,ssid,tid),that.getVolumeAdded(Exp,ssid,tid),that.getpH(Exp,ssid,tid),that.getRemark(Exp,ssid,tid));
//
// }
// else
// {
// //System.out.println("Setting titration table row using standard method:"+l);
// val = that.getTitrant(Exp,ssid,tid);
// this.setTitrant(Exp,ssid,tid,val);
//
// val = that.getTitrantConcentration(Exp,ssid,tid);
// this.setTitrantConcentration(Exp,ssid,tid,val);
//
// val = that.getVolumeAdded(Exp,ssid,tid);
// this.setVolumeAdded(Exp,ssid,tid,val);
//
// val = that.getpH(Exp,ssid,tid);
// this.setpH(Exp,ssid,tid,val);
//
// val = that.getRemark(Exp,ssid,tid);
// this.setRemark(Exp,ssid,tid,val);
// }
//
// }
//
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOff();
// }
//
// if (that instanceof BatchGetting)
// {
// ((BatchGetting)that).setBatchGettingOff();
//
// }
//
// }
// }
//
//
// }
//
// /**
// Transfer the contents of one BufferStorage to this instance.
// The transfer is done through the BufferStorage interface so is
// independent of the particular BufferStorage implementations.
// */
// public void transferStorage(RepositoryStorage th)
// {
// //System.out.println("Inside AbstractSMPBBuffer's transferstorage");
// //this.beforeTransferStorage();
// //that.beforeTransferStorage();
//
// BufferStorage that = (BufferStorage)th;
//
// long start_time = System.currentTimeMillis();
//
// this.setEnabled(that.getEnabled());
//
// this.setNickname(that.getNickname());//Watch out for cyclical behavior in class extensions' actionListers
//
//
// this.setStandardName(that.getStandardName());
// this.setCreatedBy(that.getCreatedBy());
// this.setCreatedOn(that.getCreatedOn());
//
// this.setComment(that.getComment());
//
// ////////////////////////////////////////////////////
// //Transfer the persistent predictor aspects...
//
// this.clearComplexBufferPredictorGenerator();
// //System.out.println("Finished clearBufferPredictorPersistence of AbstractSMPBuffer.");
//
//
// //System.out.println("The class is:"+that.getComplexBufferPredictorGeneratorClass());
//
//
//
//
// this.setComplexBufferPredictorGeneratorClass(that.getComplexBufferPredictorGeneratorClass());
// //System.out.println("that.getBufferPredictorPersistenceClass():"+that.getBufferPredictorPersistenceClass());
//
//
//
// Vector Exps = that.getExperimentNames();
// Vector Expsdelete;
// Vector SS,SSdelete,NN,NNdelete;
// String Exp,concentration,val,ssid,tid;
// boolean altered;
//
// Expsdelete = this.getExperimentNames();
//
// if (Exps.size()!=0)
// {
// for (int j=0;j<Exps.size();j++)
// {
//
// Exp = (String)Exps.get(j);
//
// this.transferStorage(that,Exp);
//
// }
//
// }
//
//
// //Remove any experiments not in source buffer's support.
// altered = Expsdelete.removeAll(Exps);
// if (Expsdelete.size()>0)
// {
// for (int k=0;k<Expsdelete.size();k++)
// {
// Exp = (String)Expsdelete.get(k);
// //System.out.println("About to remove :"+Exp);
// this.removeExperiment(Exp);
// }
// }
//
// // ////////////////////////////////////////////////////
// // //Transfer the persistent predictor aspects...
// //
// // this.clearComplexBufferPredictorGenerator();
// // //System.out.println("Finished clearBufferPredictorPersistence of AbstractSMPBuffer.");
// // this.setComplexBufferPredictorGeneratorClass(that.getComplexBufferPredictorGeneratorClass());
// // //System.out.println("that.getBufferPredictorPersistenceClass():"+that.getBufferPredictorPersistenceClass());
// //
// //
// //System.out.println("AbstractSMPBBuffer:There are parameters to transfer:"+parametersToTransfer.size());
//
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOn();
// }
//
// // //Invoke static method that will tell us if any ordering is necessary for the given generator...
// // Class generatorClass = null;
// // try
// // {
// // generatorClass = Class.forName(that.getComplexBufferPredictorGeneratorClass());
// // }
// // catch (java.lang.ClassNotFoundException err)
// // {
// // throw new RuntimeException("Unable to find class "+that.getComplexBufferPredictorGeneratorClass(),err);
// // }
// //
// // Object[] p = {};
// // try
// // {
// // Class[] params = {};
// // Method meth = generatorClass.getMethod("getDescriptorOrdering",params);
// // meth.invoke(null,p);
// // }
// // catch (java.lang.NoSuchMethodException err)
// // {
// // throw new RuntimeException("Unable to find method getDescriptorOrdering.",err);
// // }
// // catch (java.lang.IllegalAccessException err)
// // {
// // throw new RuntimeException("Unable to find method getDescriptorOrdering.",err);
// // }
// // catch (java.lang.reflect.InvocationTargetException err)
// // {
// // throw new RuntimeException("Unable to find method getDescriptorOrdering.",err);
// // }
//
//
//
// Vector parametersToTransfer = that.getGeneratorParameters();
// for (int j=0;j<parametersToTransfer.size();j++)
// {
// PersistentParameter param = (PersistentParameter)parametersToTransfer.get(j);
// String pname = (String)param.getName();
// //System.out.println("Parameter:"+pname);
// this.addGeneratorParameter(pname,param.getDescriptor());
// this.setGeneratorParameterValue(pname,param.getDescriptor(),param.getValue());
// }
//
//
// // if (p.length == 0)
// // {
// // Vector parametersToTransfer = that.getGeneratorParameters();
// // for (int j=0;j<parametersToTransfer.size();j++)
// // {
// // PersistentParameter param = (PersistentParameter)parametersToTransfer.get(j);
// // String pname = (String)param.getName();
// // //System.out.println("Parameter:"+pname);
// // this.addGeneratorParameter(pname,param.getDescriptor());
// // this.setGeneratorParameterValue(pname,param.getDescriptor(),param.getValue());
// // }
// // }
// // else
// // {
// // for (int k=0;k<p.length;k++)
// // {
// // String descr = (String)p[k];
// //
// // Vector parametersToTransfer = that.getGeneratorParametersForDescriptor(descr);
// // for (int j=0;j<parametersToTransfer.size();j++)
// // {
// // PersistentParameter param = (PersistentParameter)parametersToTransfer.get(j);
// // String pname = (String)param.getName();
// // //System.out.println("Parameter:"+pname);
// // this.addGeneratorParameter(pname,param.getDescriptor());
// // this.setGeneratorParameterValue(pname,param.getDescriptor(),param.getValue());
// // }
// // }
// // }
//
// if (this instanceof BatchSetting)
// {
// ((BatchSetting)this).setBatchSettingOff();
// }
//
// long stop_time = System.currentTimeMillis();
//
// //System.out.println("Total transfer time for buffer ="+(stop_time-start_time));
// }
//
abstract public String getEnabled();
abstract public void setEnabled(String n);
abstract public String getStandardName();
abstract public void setStandardName(String n);
abstract public String getNickname();
abstract public void setNickname(String n);
abstract public String getCreatedBy();
abstract public void setCreatedBy(String a);
abstract public String getCreatedOn();
abstract public void setCreatedOn(String a);
abstract public void setComment(String n);
abstract public String getComment();
//abstract public ComplexBufferPredictor getComplexPart();
//abstract public void setComplexPart(ComplexBufferPredictor smooth);
abstract public String getDescription(String exp);
abstract public void setDescription(String exp,String n);
/**
Add a new experiment with the given name to the experimental support.
*/
abstract public void addExperiment(String name);
/**
Remove an existing experiment with the given name from the experimental support.
*/
abstract public void removeExperiment(String name);
abstract public String getExperimentEnabled(String exp);
abstract public void setExperimentEnabled(String exp,String n);
abstract public String getPerformedBy(String exp);
abstract public String getPerformedOn(String exp);
/**
Identify the person who created this buffer.
*/
abstract public void setPerformedBy(String expname,String who);
/**
Identify the date and time this buffer was created.
*/
abstract public void setPerformedOn(String expname,String when);
/**
Return the experiment names of all datasets
supporting this buffer.
*/
abstract public Vector getExperimentNames();
abstract public void addBufferCoefficientsSubsample(String expname,String subsampleID);
/**
Remove the specified subsample measurements of the BufferCoefficients.
*/
abstract public void removeBufferCoefficientsSubsample(String expname,String subsampleID);
abstract public Vector getBufferCoefficientsSubsampleIDs(String expname);
abstract public void setpKa(String Experiment,String SubsampleID,String value);
abstract public String getpKa(String Experiment,String SubsampleID);
abstract public void setpKb(String Experiment,String SubsampleID,String value);
abstract public String getpKb(String Experiment,String SubsampleID);
abstract public void setSaltType(String Experiment,String SubsampleID,String value);
abstract public String getSaltType(String Experiment,String SubsampleID);
abstract public void setTemperature(String Experiment,String SubsampleID,String value);
abstract public String getTemperature(String exp,String ssid);
abstract public void setDielectric(String Experiment,String SubsampleID,String value);
abstract public String getDielectric(String exp,String ssid);
abstract public void setpHProbe(String Experiment,String SubsampleID,String value);
abstract public String getpHProbe(String exp,String ssid);
/**
Add a titration point using the given experiment name, titration subsample id
and titration point observation number.
*/
abstract public void addTitrationSubsample(String Experiment,String SubsampleID);
/**
Remove a specified titration subsample from the given experiment and titration subsample.
*/
abstract public void removeTitrationSubsample(String Experiment,String SubsampleID);
abstract public Vector getTitrationObservationNumbers(String Experiment,String SubsampleID);
abstract public Vector getTitrationSubsampleIDs(String expname);
abstract public String getInitialVolume(String expname,String titrantid);
abstract public void setInitialVolume(String expname,String titrantid,String val);
abstract public void addTitrationPoint(String Experiment,String SubsampleID,String obs);
/**
Remove the specified titration point.
*/
abstract public void removeTitrationPoint(String Experiment,String SubsampleID,String obs);
abstract public String getpH(String Experiment,String ssid,String obs);
abstract public void setpH(String expname,String ssid,String obs,String val);
abstract public String getRemark(String Experiment,String ssid,String obs);
abstract public void setRemark(String exp,String ssid,String obs,String remark);
abstract public String getTitrant(String Experiment,String ssid,String obs);
abstract public void setTitrant(String expname,String ssid,String obsnum,String nickname);
abstract public String getVolumeAdded(String Experiment,String ssid,String obs);
abstract public void setVolumeAdded(String expname,String ssid,String obsnum,String val);
abstract public String getTitrantConcentration(String Experiment,String ssid,String obs);
abstract public void setTitrantConcentration(String expname,String ssid,String obsnum,String val);
/**
Get a list of ContainedSubsampleID's for the given experiment.
*/
abstract public Vector getContainedSubsampleIDs(String expname);
abstract public Vector getContainedObservationNumbers(String exp,String ssid);
abstract public void addContainedSubsample(String exp,String ssid);
abstract public void addContainedObservation(String exp,String ssid,String obs);
/**
Remove the specified Contained entry.
*/
abstract public void removeContainedObservation(String exp,String ssid,String obs);
abstract public void removeContainedSubsample(String exp,String ssid);
abstract public String getContainedConcentration(String expname,String ssid,String obs);
abstract public void setContainedConcentration(String expname,String ssid,String obs,String val);
abstract public String getContainedNickname(String expname,String ssid,String obs);
abstract public void setContainedNickname(String expname,String ssid,String obs,String val);
}