/// <summary>
 /// 
 /// </summary>
 /// <param name="codon">The IGEPCodon that encoded for this IGEPAminoAcid.</param>
 /// <param name="useParameterlessFunction">If true, The Parameterless IFunction in the ICodon will be the IFunction
 /// that is executed.
 /// 
 /// If false, the Primary IFunction in the ICodon will be used.</param>
 protected GEPAminoAcidBase(IGEPCodon codon, bool useParameterlessFunction) 
     : base(codon)
 {
     this.Codon = codon;
     this.UseParameterlessFunction = useParameterlessFunction;
     this.Arguments = new List<IArgument>();
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="codon">If the IArgument's associated IParameter (i.e. the parameter to 
 /// which the argument is being passed) has a ParameterType of ConvertedCodon 
 /// then this is the ICodon that will be converted.</param>
 protected ArgumentUnevaluatedValueBase(IGEPCodon codon)
 {
     this.Codon = codon;
 }
 /// <summary>
 /// Adds the specified IGEPCodon to the IGEPGeneticCode.
 /// </summary>
 /// <param name="codon"></param>
 public abstract void AddCodon(IGEPCodon codon);
 /// <summary>
 /// Converts the specified IGEPCodon using the specified ICodonConverterIdentifier.
 /// </summary>
 /// <param name="codon"></param>
 /// <param name="codonConverterIdentifier"></param>
 /// <returns></returns>
 public IConvertedCodon ConvertCodon(IGEPCodon codon, ICodonConverterIdentifier codonConverterIdentifier)
 {
     return base.ConvertCodon(codon: codon, codonConverterIdentifier: codonConverterIdentifier);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="codon">If the IArgument's associated IParameter (i.e. the parameter to 
 /// which the argument is being passed) has a ParameterType of ConvertedCodon 
 /// then this is the ICodon that will be converted.</param>
 public ArgumentUnevaluatedValue(IGEPCodon codon) 
     : base(codon)
 {
 }
        private void InsertFunctionPairIfNecessary(ref FunctionPairRow functionPairRow, IGEPCodon codon)
        {
            // Insert the function pair row
            var primaryFunction = this.FunctionSet[codon.Functions.PrimaryFunction];
            var parameterlessFunction = this.FunctionSet[codon.Functions.ParameterlessFunction];

            var primaryFunctionPrimaryKey =
                primaryFunction.ToFunctionRow(this.GeneticCodePrimaryKey.Value).GetPrimaryKeyByColumnsDefiningUniqueness().ToInt();
            var parameterlessFunctionPrimaryKey =
                parameterlessFunction.ToFunctionRow(this.GeneticCodePrimaryKey.Value).GetPrimaryKeyByColumnsDefiningUniqueness().ToInt();

            functionPairRow = new FunctionPairRow(primaryFunction: primaryFunctionPrimaryKey,
                                                  parameterlessFunction: parameterlessFunctionPrimaryKey,
                                                  primaryFunctionIdentifier: primaryFunction.Identifier.ToString(),
                                                  parameterlessFunctionIdentifier:
                                                      parameterlessFunction.Identifier.ToString(),
                                                  geneticCode: this.GeneticCodePrimaryKey.Value);
            functionPairRow.InsertOnlyIfNecessary();
        }
        public override void AddCodon(IGEPCodon codon)
        {
            var functionPairRow = new FunctionPairRow();
            var result = Qry.SelectAllFrom(functionPairRow)
                .InnerJoinOn(functionPairRow.PrimaryFunctionRowColumn)
                .InnerJoinOn(functionPairRow.ParameterlessFunctionRowColumn)
                .Where(functionPairRow.PrimaryFunctionRow.FunctionIdentifierColumn, codon.Functions.PrimaryFunction.ToString())
                .Where(functionPairRow.ParameterlessFunctionRow.FunctionIdentifierColumn, codon.Functions.ParameterlessFunction.ToString())
                .Go();
            
            if(result.IsEmpty)
                this.InsertFunctionPairIfNecessary(ref functionPairRow, codon: codon);
            else
                result.ExtractStrongRow(ref functionPairRow);

            var codonRow = new CodonRow(name: codon.CodonIdentifier.ToString(), geneticCode: this.GeneticCodePrimaryKey.Value,
                                        functionPair: functionPairRow.PrimaryKey, codonType: codon.CodonType.ToCodonType());
            codonRow.InsertIntoDatabase();

            /*
            var nucleotideRow = new NucleotideRow();
            var nucleotideRows = Qry.SelectAllFrom(nucleotideRow)
                .Where(nucleotideRow.GeneticCodeColumn, this.GeneticCodePrimaryKey.Value)
                .GoAndExtractMultiple<NucleotideRow>();

            foreach(var nucleotide in codon)
            {
                var codonNucleotideRow =
                    nucleotide.ToCodonNucleotideRow(
                        nucleotidePrimaryKey:
                            nucleotideRows.First(n => n.Name == nucleotide.Identifier.ToString()).PrimaryKey,
                        codonPrimaryKey: codonRow.PrimaryKey,
                        geneticCodePrimaryKey: this.GeneticCodePrimaryKey.Value);
                codonNucleotideRow.InsertOnlyIfNecessary();
            }
             */
        }
 public override void AddCodon(IGEPCodon codon)
 {
     this.Codons.Add(codon.CodonIdentifier, codon);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="codon">The IGEPCodon that encoded for this IGEPAminoAcid.</param>
 /// <param name="useParameterlessFunction">If true, The Parameterless IFunction in the ICodon will be the IFunction
 /// that is executed.
 /// 
 /// If false, the Primary IFunction in the ICodon will be used.</param>
 public GEPAminoAcid(IGEPCodon codon, bool useParameterlessFunction) 
     : base(codon, useParameterlessFunction)
 {
 }