static void Main() { //Problem 1. Point3D Console.WriteLine("Problem 1. Point3D"); Console.WriteLine("--------------------"); Point p1 = new Point(1, 2, 3); Point p2 = new Point(3.4, 4.66, 5.55); Console.WriteLine(p1); Console.WriteLine(p2); Console.WriteLine(Point.StartPoint); Console.WriteLine(); //Problem 2. Distance Calculator Console.WriteLine("Problem 2. Distance Calculator"); Console.WriteLine("-------------------------------"); double distance = DistanceCalculator.CalculateDistance(p1, p2); Console.WriteLine(distance); Console.WriteLine(); //Problem 3. Paths Console.WriteLine("Problem 3. Paths"); Console.WriteLine("-------------------------------"); Path path = new Path(p1, p2, Point.StartPoint); Console.WriteLine("Save path: {0}", path); Storage.SavePathInFile("path.txt", path); Path loadPath = Storage.LoadPathOfFile("path.txt"); Console.WriteLine("Load path: {0}", loadPath); }
static void Main() { Point3D firstPoint = new Point3D("First Point", -7, -4, 3); Point3D secondPoint = new Point3D("Second Point", 17, 6, 2.5); Console.WriteLine("The distance between the two points is : {0}", DistanceCalculator.CalculateDistance(firstPoint, secondPoint)); }
static void Main() { Point3D a = new Point3D(-7, -4, 3); Point3D b = new Point3D(17, 6, 2.5); Console.WriteLine(DistanceCalculator.CalculateDistance(a, b)); }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); // generateLocations(); // generateRelations(); var pointRelationships = JsonSerializer.Deserialize <IReadOnlyList <PointRelationship> >(File.ReadAllText(pointRelationshipPath)); var nodeConnector = new NodeConnector(); var sw = new Stopwatch(); Console.WriteLine("connect start"); sw.Start(); var pointNodes = nodeConnector.Connect(pointRelationships); sw.Stop(); Console.WriteLine($"connect stop: {sw.ElapsedMilliseconds}"); var distanceCalculator = new DistanceCalculator(); string source = "1520000"; string target = "2610012"; Console.WriteLine("calculate start"); sw.Reset(); sw.Start(); Console.WriteLine($"{source}~{target}: {distanceCalculator.CalculateDistance(pointNodes, source, target)}m"); sw.Stop(); Console.WriteLine($"calculate stop: {sw.ElapsedMilliseconds}"); }
private static void Main() { Console.WriteLine("Problem 1. Point3D"); Point3D p1 = new Point3D(1, 2, 3); Point3D p2 = new Point3D(3.4, 4.66, 5.55); Console.WriteLine(p1); Console.WriteLine(p2); Console.WriteLine(Point3D.StartPoint); Console.WriteLine(); Console.WriteLine("Problem 2. Distance Calculator"); double distance = DistanceCalculator.CalculateDistance(p1, p2); Console.WriteLine(distance); Console.WriteLine(); Console.WriteLine("Problem 3. Paths3D"); Path3D path = new Path3D(p1, p2, Point3D.StartPoint); Console.WriteLine("Save path: {0}", path); Storage.SavePathInFile("path.txt", path); Path3D loadPath = Storage.LoadPathOfFile("path.txt"); Console.WriteLine("Load path: {0}", loadPath); }
public void DistanceCalculationwithTwoContigs() { const int KmerLength = 6; IList <ISequence> sequences = new List <ISequence>() { new Sequence(Alphabets.DNA, "GATCTGATAA") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor substrate 1 (IRS1) on chromosome 2.X1:0.5K" }, new Sequence(Alphabets.DNA, "ATCTGATAAG") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor on chromosome 2.F:0.5K" }, new Sequence(Alphabets.DNA, "TCTGATAAGG") { ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor on chromosome 2.2:0.5K" }, new Sequence(Alphabets.DNA, "TTTTTGATGG") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor substrate 1 (IRS1) on chromosome 2.Y1:0.5K" }, new Sequence(Alphabets.DNA, "TTTTGATGGC") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor on chromosome 2.R:0.5K" }, new Sequence(Alphabets.DNA, "TTTGATGGCA") { ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor on chromosome 2.1:0.5K" } }; IList <ISequence> contigs = new List <ISequence> { new Sequence(Alphabets.DNA, "GATCTGATAAGG"), new Sequence(Alphabets.DNA, "TTTTTGATGGCA") }; ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, KmerLength); MatePairMapper mapPairedReads = new MatePairMapper(); ContigMatePairs pairs = mapPairedReads.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairs); DistanceCalculator calc = new DistanceCalculator(contigpairedReads); contigpairedReads = calc.CalculateDistance(); Assert.AreEqual(contigpairedReads.Values.Count, 1); Assert.IsTrue(contigpairedReads.ContainsKey(contigs[0])); Dictionary <ISequence, IList <ValidMatePair> > map = contigpairedReads[contigs[0]]; Assert.IsTrue(map.ContainsKey(contigs[1])); IList <ValidMatePair> valid = map[contigs[1]]; Assert.AreEqual(valid.First().DistanceBetweenContigs[0], (float)478.000031); Assert.AreEqual(valid.First().DistanceBetweenContigs[1], (float)477.0); Assert.AreEqual(valid.First().StandardDeviation[0], (float)14.1421356); Assert.AreEqual(valid.First().StandardDeviation[1], (float)14.1421356); Assert.AreEqual(valid.First().Weight, 2); }
public void DistanceCalculationwithTwoContigsWeightedMean() { const int KmerLength = 6; List <ISequence> sequences = new List <ISequence>(); Sequence seq = new Sequence(Alphabets.DNA, "GATCTGATAA".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "substrate 1 (IRS1) on chromosome 2.x1:2K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "ATCTGATAAG".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "on chromosome 2.f:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TCTGATAAGG".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor" + "on chromosome 2.2:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTGATGG".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "substrate 1 (IRS1) on chromosome 2.y1:2K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTGATGGC".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "on chromosome 2.r:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTGATGGCA".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor" + "on chromosome 2.1:0.5K"; sequences.Add(seq); IList <ISequence> contigs = new List <ISequence> { new Sequence(Alphabets.DNA, "GATCTGATAAGG".Select(a => (byte)a).ToArray()), new Sequence(Alphabets.DNA, "TTTTTGATGGCA".Select(a => (byte)a).ToArray()) }; ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, KmerLength); MatePairMapper mapPairedReads = new MatePairMapper(); ContigMatePairs pairedReads = mapPairedReads.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairedReads); DistanceCalculator calc = new DistanceCalculator(contigpairedReads); contigpairedReads = calc.CalculateDistance(); Assert.AreEqual(contigpairedReads.Values.Count, 1); Assert.IsTrue(contigpairedReads.ContainsKey(contigs[0])); Dictionary <ISequence, IList <ValidMatePair> > map = contigpairedReads[contigs[0]]; Assert.IsTrue(map.ContainsKey(contigs[1])); IList <ValidMatePair> valid = map[contigs[1]]; Assert.AreEqual(valid.First().DistanceBetweenContigs[0], (float)1228.0); Assert.AreEqual(valid.First().DistanceBetweenContigs[1], (float)1227.0); Assert.AreEqual(valid.First().StandardDeviation[0], (float)60); Assert.AreEqual(valid.First().StandardDeviation[1], (float)60); Assert.AreEqual(valid.First().Weight, 2); }
public double CalculateDistance(List <Point3D> listOfPoints) { double result = 0; for (int i = 0; i < listOfPoints.Count - 1; i++) { result += DistanceCalculator.CalculateDistance(listOfPoints[i], listOfPoints[i + 1]); } return(result); }
public void CalculateDistanceTest() { DistanceCalculator target = new DistanceCalculator(); // TODO: Initialize to an appropriate value double time = 5; // TODO: Initialize to an appropriate value double speed = 6; // TODO: Initialize to an appropriate value double expected = 30; // TODO: Initialize to an appropriate value double actual; actual = target.CalculateDistance(time, speed); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public void CalculateDistanceForLeg() { var locations = new LocationRepository().GetAll(); var hookNorton = locations.First(l => l.Name.StartsWith("Hook Norton")); var theBridge = locations.First(l => l.Name.StartsWith("The Bridge")); var dist = DistanceCalculator.CalculateDistance(hookNorton, theBridge); dist.Should().BeApproximately(144.738, 0.1); }
static void Main() { Console.WriteLine(Point3D.StartingPoint); Console.WriteLine(); var point_1 = new Point3D(2, 4, 6); var point_2 = new Point3D(1, 6, 4); double distace = DistanceCalculator.CalculateDistance(point_1, point_2); Console.WriteLine(distace); }
public void Should_Correctly_Generate_Distance() { // verified manually first using an online distance calculator -> https://www.vcalc.com/wiki/vCalc/Haversine+-+Distance var latFrom = 53.339428; var longFrom = -6.257664; Assert.Equal(42, DistanceCalculator.CalculateDistance(latFrom, longFrom, 52.986375, -6.043701)); Assert.Equal(313, DistanceCalculator.CalculateDistance(latFrom, longFrom, 51.92893, -10.27699)); Assert.Equal(302, DistanceCalculator.CalculateDistance(latFrom, longFrom, 52.3191841, -10.4240951)); Assert.Equal(222, DistanceCalculator.CalculateDistance(latFrom, longFrom, 51.8856167, -8.5072391)); Assert.Equal(109, DistanceCalculator.CalculateDistance(latFrom, longFrom, 53.807778, -7.714444)); }
public void DistanceCalculation() { var termWeightRepresentation = new Mock<ITermWeightRepresentation>(); termWeightRepresentation.Setup(x => x.TermWeight(It.Is<string>(y => y == "bee"))).Returns(0.91629); termWeightRepresentation.Setup(x => x.TermWeight(It.Is<string>(y => y == "wasp"))).Returns(0.91629); termWeightRepresentation.Setup(x => x.TermWeight(It.Is<string>(y => y == "fly"))).Returns(0.22314); var termsCollection = new TermsCollection(new[] {"bee", "wasp", "fly", "fruit", "like"}); var distanceCalculator = new DistanceCalculator(); double actualDistance = distanceCalculator.CalculateDistance(termWeightRepresentation.Object, termsCollection); Assert.AreEqual(1.314903211, actualDistance, 0.0001); }
protected void btnCalculate_Click(object sender, EventArgs e) { try { DistanceCalculator distanceCalculator = new DistanceCalculator(); lblDistance.Text = distanceCalculator.CalculateDistance (Convert.ToDouble(txtTime.Text), Convert.ToDouble(txtSpeed.Text)).ToString(); } catch (Exception ex) { lblDistance.Text = ex.Message; } }
private void GenerateRecsForNodeArray() { List <Node> nodes = new List <Node>(); MemoryTree.ToList(nodes); nodes = nodes.Except(CurrentUser.NotShow).Except(CurrentUser.Favourite).ToList(); foreach (Node node in nodes) { node.Distance = 0.0; foreach (Node n in CurrentUser.Favourite) { DistanceCalculator calculator = new DistanceCalculator(node, n); node.Distance += calculator.CalculateDistance((MeasureType)MeasureTypeIndex); } node.Distance /= (double)CurrentUser.Favourite.Count(); } nodes.Sort(delegate(Node node1, Node node2) { if (node1 == null && node2 == null) { return(0); } if (node1 == null) { return(-1); } if (node2 == null) { return(1); } if (node1.Distance == node2.Distance) { return(0); } if (node1.Distance > node2.Distance) { return(1); } return(-1); }); Recommendations = new ObservableCollection <Node>(nodes.Take(UsersCount)); AddRecommendationsToItems(); }
private IEnumerable <Node> GenerateRecsForNodeArray() { var nodes = new List <Node>(); MemoryTree.ToList(nodes); nodes = nodes.Except(CurrentUser.NotShow).Except(CurrentUser.Favourite).ToList(); foreach (var node in nodes) { node.Distance = 0.0; foreach (var n in CurrentUser.Favourite) { var calculator = new DistanceCalculator(node, n); node.Distance += calculator.CalculateDistance((MeasureType)MeasureTypeIndex); } node.Distance /= (double)CurrentUser.Favourite.Count(); } nodes.Sort(delegate(Node node1, Node node2) { if (node1 == null && node2 == null) { return(0); } if (node1 == null) { return(-1); } if (node2 == null) { return(1); } if (node1.Distance == node2.Distance) { return(0); } if (node1.Distance > node2.Distance) { return(1); } return(-1); }); return(nodes); }
static void Main(string[] args) { Console.WriteLine("Day1 Star1"); FuelRequirementsCalculator fuelRequirementsCalculator = new FuelRequirementsCalculator(); Console.WriteLine($"Result: {fuelRequirementsCalculator.CalculateTotalFuelRequirements(InputReader.InputReader.ReadDay1Input())}"); Console.WriteLine(); Console.WriteLine("Day1 Star2"); Day1.Star2.FuelRequirementsCalculator fuelRequirementsCalculator2 = new Day1.Star2.FuelRequirementsCalculator(); Console.WriteLine($"Result: {fuelRequirementsCalculator2.CalculateTotalFuelRequirements(InputReader.InputReader.ReadDay1Input())}"); Console.WriteLine(); Console.WriteLine("Day 2 Star1"); IntCodeComputer intCodeComputer = new IntCodeComputer(); Console.WriteLine($"Result {intCodeComputer.Process(InputReader.InputReader.ReadDay2Input())}"); Console.WriteLine(); Console.WriteLine("Day 2 Star2"); Day2.Star2.IntCodeComputer intCodeComputer2 = new Day2.Star2.IntCodeComputer(); Console.WriteLine($"Result: {intCodeComputer2.FindInputsToProduceValue(InputReader.InputReader.ReadDay2Input(), 19690720)}"); Console.WriteLine(); Console.WriteLine("Day3 Star1"); DistanceCalculator distanceCalculator = new DistanceCalculator(); Console.WriteLine($"Result {distanceCalculator.CalculateDistance(InputReader.InputReader.ReadDay3Input())}"); Console.WriteLine(); Console.WriteLine("Day3 Star2"); Day3.Star2.DistanceCalculator distanceCalculator2 = new Day3.Star2.DistanceCalculator(); Console.WriteLine($"Result {distanceCalculator2.CalculateDistance(InputReader.InputReader.ReadDay3SmallInput())}"); Console.WriteLine(); Console.WriteLine("Day4 Star1"); PasswordFinder passwordFinder = new PasswordFinder(); Console.WriteLine($"Result: {passwordFinder.FindPossiblePasswords(145852, 616942).Count()}"); Console.WriteLine(); Console.WriteLine("Day4 Star2"); Day4.Star2.PasswordFinder passwordFinder2 = new Day4.Star2.PasswordFinder(); Console.WriteLine($"Result {passwordFinder2.FindPossiblePasswords(145852, 616942).Count()}"); }
static void Main() { Console.WriteLine("Please enter coordinates of the first point separated by space:"); string coordinates = Console.ReadLine(); string[] tempString = coordinates.Split(' '); double x1 = double.Parse(tempString[0]); double y1 = double.Parse(tempString[1]); double z1 = double.Parse(tempString[2]); Console.WriteLine("Please enter coordinates of the second point separated by space:"); coordinates = Console.ReadLine(); tempString = coordinates.Split(' '); double x2 = double.Parse(tempString[0]); double y2 = double.Parse(tempString[1]); double z2 = double.Parse(tempString[2]); Console.WriteLine(DistanceCalculator.CalculateDistance(x1, y1, z1, x2, y2, z2)); }
private void GenerateRecsForSingleNode(Node node) { List <Node> nodes = new List <Node>(); MemoryTree.ToList(nodes); nodes = nodes.Except(CurrentUser.NotShow).Except(new[] { node }).ToList(); foreach (Node n in nodes) { DistanceCalculator calculator = new DistanceCalculator(node, n); n.Distance = calculator.CalculateDistance((MeasureType)MeasureTypeIndex); } nodes.Sort(delegate(Node node1, Node node2) { if (node1 == null && node2 == null) { return(0); } if (node1 == null) { return(-1); } if (node2 == null) { return(1); } if (node1.Distance == node2.Distance) { return(0); } if (node1.Distance > node2.Distance) { return(1); } return(-1); }); Recommendations = new ObservableCollection <Node>(nodes.Take(RecsLength)); AddRecommendationsToItems(); }
private IEnumerable <Node> GenerateRecsForSingleNode(Node node) { var nodes = new List <Node>(); MemoryTree.ToList(nodes); nodes = nodes.Except(CurrentUser.NotShow).Except(new[] { node }).ToList(); foreach (var n in nodes) { var calculator = new DistanceCalculator(node, n); n.Distance = calculator.CalculateDistance((MeasureType)MeasureTypeIndex); } nodes.Sort(delegate(Node node1, Node node2) { if (node1 == null && node2 == null) { return(0); } if (node1 == null) { return(-1); } if (node2 == null) { return(1); } if (node1.Distance == node2.Distance) { return(0); } if (node1.Distance > node2.Distance) { return(1); } return(-1); }); return(nodes); }
public override void Train(TrainingParameters parameters) { SomTrainingParameters p = (SomTrainingParameters)parameters; try { parameters.Validate(); } catch (TrainingParametersException e) { throw new SomLogicalException($"Improper training parameters. {e.Message}"); } var trainingData = p.TrainingData; var iterations = p.NumberOfIterations; var neighborhoodFunction = p.NeighbourhoodFunction; var learningRate = p.LearningRate; var tiredness = p.TirednessMechanism; if (trainingData.First().Count != Dimensions) { throw new SomLogicalException("Training data points dimensions doesn't match som dimensions."); } tiredness?.Initialize(Neurons); Observer?.SaveState(Neurons); int numberOfShuffles = (iterations / trainingData.Count) + 1; for (int j = 0; j < numberOfShuffles; j++) { var shuffled = trainingData.Shuffle(); for (int i = 0; i < shuffled.Count; i++) { if (j * shuffled.Count + i == iterations) { return; } Dictionary <Neuron, double> neuronsDistances = new Dictionary <Neuron, double>(); for (int k = 0; k < Neurons.Count; k++) { //store neurons with their distances neuronsDistances.Add(Neurons[k], DistanceCalculator.CalculateDistance(shuffled[i], Neurons[k].CurrentWeights)); } var potentialWinners = tiredness == null ? Neurons : tiredness.SelectPotentialWinners(Neurons); Neuron winner = neuronsDistances.Where(pair => potentialWinners.Contains(pair.Key)) .OrderBy(pair => pair.Value).First().Key; tiredness?.Update(winner, Neurons); var neuronsNeighbourhoodCoefficients = neighborhoodFunction.CalculateNeighborhoodValues(winner, neuronsDistances, DistanceCalculator, j * trainingData.Count + i); foreach (var neuron in Neurons) { var diffVec = shuffled[i].Subtract(neuron.CurrentWeights); var deltaWeight = diffVec.Multiply(learningRate.GetValue(j * trainingData.Count + i) * neuronsNeighbourhoodCoefficients[neuron]); neuron.CurrentWeights = neuron.CurrentWeights + deltaWeight; } Observer?.SaveState(Neurons); } } }
public override void Train(TrainingParameters parameters) { KMeansTrainingParameters p = (KMeansTrainingParameters)parameters; try { p.Validate(); } catch (TrainingParametersException e) { throw new SomLogicalException($"Improper training parameters. {e.Message}"); } var trainingData = parameters.TrainingData; var epochs = p.Epochs; if (trainingData.First().Count != Dimensions) { throw new SomLogicalException("Training data points dimensions doesn't match som dimensions."); } Observer?.SaveState(Neurons); bool end = false; for (int j = 0; j < epochs && !end; j++) { var shuffled = trainingData.Shuffle(); Dictionary <Neuron, List <Vector <double> > > neuronsZones = new Dictionary <Neuron, List <Vector <double> > >(); foreach (var neuron in Neurons) { neuronsZones.Add(neuron, new List <Vector <double> >()); } for (int i = 0; i < shuffled.Count; i++) { Dictionary <Neuron, double> neuronsDistances = new Dictionary <Neuron, double>(); for (int k = 0; k < Neurons.Count; k++) { //store neurons with their distances neuronsDistances.Add(Neurons[k], DistanceCalculator.CalculateDistance(shuffled[i], Neurons[k].CurrentWeights)); } Neuron winner = neuronsDistances.OrderBy(pair => pair.Value).First().Key; neuronsZones[winner].Add(shuffled[i]); } var aggregate = Vector <double> .Build.DenseOfEnumerable(new List <double>(new double[Dimensions])); end = true; foreach (var pair in neuronsZones) { foreach (var vec in pair.Value) { aggregate = aggregate.Add(vec); } if (pair.Value.Count != 0) { aggregate = aggregate.Divide(pair.Value.Count); var diff = aggregate.Subtract(pair.Key.CurrentWeights).Map(Math.Abs).Sum(); if (end && diff > 0.0001) { end = false; } pair.Key.CurrentWeights = aggregate; } } Observer?.SaveState(Neurons); } }
public void CalculateDistance_CalculatingDistance_DistanceIsCorrect(double x1, double x2, double y1, double y2, double distance) { Assert.That(_uut.CalculateDistance(x1, x2, y1, y2), Is.EqualTo(distance).Within(0.5)); }
public void TracePathTestWithPalindromicContig() { const int kmerLength = 6; const int dangleThreshold = 3; const int redundantThreshold = 7; List <ISequence> sequences = new List <ISequence>(); Sequence seq = new Sequence(Alphabets.DNA, "ATGCCTC"); seq.DisplayID = ">10.x1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "CCTCCTAT"); seq.DisplayID = "1"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TCCTATC"); seq.DisplayID = "2"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TGCCTCCT"); seq.DisplayID = "3"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "ATCTTAGC"); seq.DisplayID = "4"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "CTATCTTAG"); seq.DisplayID = "5"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "CTTAGCG"); seq.DisplayID = "6"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "GCCTCCTAT"); seq.DisplayID = ">8.x1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TAGCGCGCTA"); seq.DisplayID = ">8.y1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "AGCGCGC"); seq.DisplayID = ">9.x1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTT"); seq.DisplayID = "7"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTAAA"); seq.DisplayID = "8"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TAAAAA"); seq.DisplayID = "9"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTAG"); seq.DisplayID = "10"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTAGC"); seq.DisplayID = "11"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "GCGCGCCGCGCG"); seq.DisplayID = "12"; sequences.Add(seq); KmerLength = kmerLength; SequenceReads.Clear(); AddSequenceReads(sequences); CreateGraph(); DanglingLinksThreshold = dangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(dangleThreshold); RedundantPathLengthThreshold = redundantThreshold; RedundantPathsPurger = new RedundantPathsPurger(redundantThreshold); UnDangleGraph(); RemoveRedundancy(); IList <ISequence> contigs = BuildContigs(); ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, kmerLength); MatePairMapper builder = new MatePairMapper(); CloneLibrary.Instance.AddLibrary("abc", (float)5, (float)15); ContigMatePairs pairedReads = builder.MapContigToMatePairs(sequences, maps); ContigMatePairs overlap; OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); overlap = filter.FilterPairedReads(pairedReads, 0); DistanceCalculator dist = new DistanceCalculator(); dist.CalculateDistance(overlap); Graph.BuildContigGraph(contigs, this.KmerLength); TracePath path = new TracePath(); IList <ScaffoldPath> paths = path.FindPaths(Graph, overlap, kmerLength, 3); Assert.AreEqual(paths.Count, 3); Assert.AreEqual(paths.First().Count, 3); ScaffoldPath scaffold = paths.First(); DeBruijnGraph graph = Graph; Assert.IsTrue(graph.GetNodeSequence(scaffold[0].Key).ToString().Equals("ATGCCTCCTATCTTAGC")); Assert.IsTrue(graph.GetNodeSequence(scaffold[1].Key).ToString().Equals("TTAGCGCG")); Assert.IsTrue(graph.GetNodeSequence(scaffold[2].Key).ToString().Equals("GCGCGC")); }
//CALCULA LA DISTANCIA CON 6 PUNTOS DADOS PARA QUE COJA UN CAMINO CORRECTO ANTES DE IR HACIA CASA DE ROSITA void CalculateDistance() { dateRositaRoutine = distanceCalculatorScript.CalculateDistance(auxiliarPoints); specialRoutines[0] = dateRositaRoutine; }
public void TracePathTestWithPalindromicContig() { const int kmerLengthConst = 5; const int dangleThreshold = 3; const int redundantThreshold = 6; var sequences = new List <ISequence>() { new Sequence(Alphabets.DNA, "ATGCCTC") { ID = "0" }, new Sequence(Alphabets.DNA, "CCTCCTAT") { ID = "1" }, new Sequence(Alphabets.DNA, "TCCTATC") { ID = "2" }, new Sequence(Alphabets.DNA, "TGCCTCCT") { ID = "3" }, new Sequence(Alphabets.DNA, "ATCTTAGC") { ID = "4" }, new Sequence(Alphabets.DNA, "CTATCTTAG") { ID = "5" }, new Sequence(Alphabets.DNA, "CTTAGCG") { ID = "6" }, new Sequence(Alphabets.DNA, "GCCTCCTAT") { ID = "7" }, new Sequence(Alphabets.DNA, "TAGCGCGCTA") { ID = "8" }, new Sequence(Alphabets.DNA, "AGCGCGC") { ID = "9" }, new Sequence(Alphabets.DNA, "TTTTTT") { ID = "10" }, new Sequence(Alphabets.DNA, "TTTTTAAA") { ID = "11" }, new Sequence(Alphabets.DNA, "TAAAAA") { ID = "12" }, new Sequence(Alphabets.DNA, "TTTTAG") { ID = "13" }, new Sequence(Alphabets.DNA, "TTTAGC") { ID = "14" }, new Sequence(Alphabets.DNA, "GCGCGCCGCGCG") { ID = "15" }, }; KmerLength = kmerLengthConst; SequenceReads.Clear(); SetSequenceReads(sequences); CreateGraph(); DanglingLinksThreshold = dangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(dangleThreshold); RedundantPathLengthThreshold = redundantThreshold; RedundantPathsPurger = new RedundantPathsPurger(redundantThreshold); UnDangleGraph(); RemoveRedundancy(); IList <ISequence> contigs = BuildContigs().ToList(); ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, kmerLengthConst); MatePairMapper builder = new MatePairMapper(); CloneLibrary.Instance.AddLibrary("abc", 5, 15); ContigMatePairs pairedReads = builder.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs overlap = filter.FilterPairedReads(pairedReads, 0); DistanceCalculator dist = new DistanceCalculator(overlap); overlap = dist.CalculateDistance(); ContigGraph graph = new ContigGraph(); graph.BuildContigGraph(contigs, this.KmerLength); TracePath path = new TracePath(); IList <ScaffoldPath> paths = path.FindPaths(graph, overlap, kmerLengthConst, 3); Assert.AreEqual(paths.Count, 3); Assert.AreEqual(paths.First().Count, 3); ScaffoldPath scaffold = paths.First(); Assert.AreEqual("ATGCCTCCTATCTTAGC", graph.GetNodeSequence(scaffold[0].Key).ConvertToString()); Assert.AreEqual("TTAGCGCG", graph.GetNodeSequence(scaffold[1].Key).ConvertToString()); Assert.AreEqual("GCGCGC", graph.GetNodeSequence(scaffold[2].Key).ConvertToString()); }