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(); } */ }