public override ICodon GetRandomCodon() { // Construct a Codon (randomly). var codonName = ""; for (var i = 0; i < this.CodonLength; i++) { var nucleotide = this.Nucleotides.Values.RandomElement(); codonName += nucleotide.Identifier.ToString(); } var codonRow = new CodonRow(); Qry.SelectAllFrom(codonRow) .InnerJoinSelectingAllOn(codonRow.FunctionPairRowColumn) .Where(codonRow.NameColumn, codonName) .GoAndExtract(ref codonRow); return codonRow.ToGEPCodon(this); }
public override IEnumerable<ICodon> GetStopCodons() { var codonRow = new CodonRow(); var codonRows = Qry.SelectAllFrom(codonRow) .InnerJoinSelectingAllOn(codonRow.FunctionPairRowColumn) .Where(codonRow.CodonTypeColumn, CodonType.Stop) .GoAndExtractMultiple<CodonRow>(); return codonRows.Select(c => c.ToGEPCodon(this)); }
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 IGEPCodon GetCodonEncodingFunction(IFunctionIdentifier functionIdentifier, CodonType codonType = CodonType.Standard) { var codonRow = new CodonRow(); Qry.SelectAllFrom(codonRow) .InnerJoinSelectingAllOn(codonRow.FunctionPairRowColumn) .InnerJoinOn(codonRow.FunctionPairRow.PrimaryFunctionRowColumn) .Where(codonRow.CodonTypeColumn, codonType.ToString()) .Where(codonRow.FunctionPairRow.PrimaryFunctionRow.FunctionIdentifierColumn, functionIdentifier.ToString()) .GoAndExtract(ref codonRow); return codonRow.ToGEPCodon(this); }
public override ICodon GetCodon(ICodonIdentifier codonIdentifier) { var codonRow = new CodonRow(); Qry.SelectAllFrom(codonRow) .InnerJoinSelectingAllOn(codonRow.FunctionPairRowColumn) .Where(codonRow.NameColumn, codonIdentifier.ToString()) .GoAndExtract(ref codonRow); return codonRow.ToGEPCodon(this); }