/// <summary> /// Construct a calculator with selected distance function /// /// A distance function is assigned to the class and it is /// read-only for a given set of input sequences. /// </summary> /// <param name="kmerLength">positive integer kmer length</param> /// <param name="moleculeType">molecule type: DNA, RNA or Protein</param> /// <param name="DistanceFunctionName">DistanceFunctionTypes member</param> public KmerDistanceScoreCalculator(int kmerLength, MoleculeType moleculeType, DistanceFunctionTypes DistanceFunctionName) { if (kmerLength <= 0) { throw new ArgumentException("Kmer length needs to be positive"); } _kmerLength = kmerLength; switch (moleculeType) { case (MoleculeType.DNA): _numberOfPossibleKmers = (int)Math.Pow(15, _kmerLength); break; case (MoleculeType.RNA): _numberOfPossibleKmers = (int)Math.Pow(15, _kmerLength); break; case (MoleculeType.Protein): _numberOfPossibleKmers = (int)Math.Pow(25, _kmerLength); break; default: throw new Exception("Invalid molecular type"); } switch (DistanceFunctionName) { case (DistanceFunctionTypes.EuclideanDistance): _distanceFunction = new DistanceFunctionSelector(EuclideanDistance); break; case (DistanceFunctionTypes.CoVariance): _distanceFunction = new DistanceFunctionSelector(CoVariance); break; case (DistanceFunctionTypes.PearsonCorrelation): _distanceFunction = new DistanceFunctionSelector(PearsonCorrelation); break; case (DistanceFunctionTypes.ModifiedMUSCLE): _distanceFunction = new DistanceFunctionSelector(ModifiedMUSCLE); break; default: throw new ArgumentException("Similarity Function Name is not in the list..."); } }
/// <summary> /// Construct a calculator with selected distance function /// /// A distance function is assigned to the class and it is /// read-only for a given set of input sequences. /// </summary> /// <param name="kmerLength">positive integer kmer length</param> /// <param name="alphabetType">molecule type: DNA, RNA or Protein</param> /// <param name="DistanceFunctionName">DistanceFunctionTypes member</param> public KmerDistanceScoreCalculator(int kmerLength, IAlphabet alphabetType, DistanceFunctionTypes DistanceFunctionName) { if (kmerLength <= 0) { throw new ArgumentException("Kmer length needs to be positive"); } _kmerLength = kmerLength; if (alphabetType is DnaAlphabet) { _numberOfPossibleKmers = (int)Math.Pow(15, _kmerLength); } else if (alphabetType is RnaAlphabet) { _numberOfPossibleKmers = (int)Math.Pow(15, _kmerLength); } else if (alphabetType is ProteinAlphabet) { _numberOfPossibleKmers = (int)Math.Pow(25, _kmerLength); } else { throw new Exception("Invalid molecular type"); } switch (DistanceFunctionName) { case (DistanceFunctionTypes.EuclideanDistance): _distanceFunction = new DistanceFunctionSelector(EuclideanDistance); break; case (DistanceFunctionTypes.CoVariance): _distanceFunction = new DistanceFunctionSelector(CoVariance); break; case (DistanceFunctionTypes.PearsonCorrelation): _distanceFunction = new DistanceFunctionSelector(PearsonCorrelation); break; case (DistanceFunctionTypes.ModifiedMUSCLE): _distanceFunction = new DistanceFunctionSelector(ModifiedMUSCLE); break; default: throw new ArgumentException("Similarity Function Name is not in the list..."); } }