コード例 #1
0
        public static List <VeadGroup> GetSampleVeadGroups(int numVeads = 4, int numVeadGroups = 1, bool useAlternateVariantSites = false, string prefix = "")
        {
            var veadgroups = new List <VeadGroup>();

            for (int i = 0; i < numVeadGroups; i++)
            {
                var veads = new List <Vead>();

                for (int j = 0; j < numVeads; j++)
                {
                    Vead vead;
                    if (useAlternateVariantSites)
                    {
                        vead = PhasedVariantTestUtilities.CreateVeadFromStringArray(prefix + "r" + i * j, new[, ] {
                            { "C", "C" }, { "G", "A" }
                        });
                    }
                    else
                    {
                        vead = PhasedVariantTestUtilities.CreateVeadFromStringArray(prefix + "r" + i * j, new[, ] {
                            { "A", "T" }, { "G", "C" }
                        });
                    }
                    veads.Add(vead);
                }

                veadgroups.Add(PhasedVariantTestUtilities.CreateVeadGroup(veads));
            }

            return(veadgroups);
        }
コード例 #2
0
        public void AddMnvsFromClusters()
        {
            //TODO even with mock cluster this takes too much setting up.
            var nbhd = new VcfNeighborhood(new VariantCallingParameters(), "chr1", new VariantSite(120), new VariantSite(121), "T");

            var vead = PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var vead2 = PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var vead3 = PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var veads = new List <Vead> {
                vead, vead2, vead3
            };

            nbhd.ReferenceSequence = "CGT";

            var mockCluster = new Mock <ICluster>();

            mockCluster.Setup(c => c.CountsAtSites).Returns(new[] { 10, 3, 5 });
            var consensus = PhasedVariantTestUtilities.CreateVeadGroup(veads);

            mockCluster.Setup(c => c.GetConsensusSites()).Returns(consensus.SiteResults);
            mockCluster.Setup(c => c.GetVeadGroups()).Returns(new List <VeadGroup>()
            {
                consensus
            });
            nbhd.AddMnvsFromClusters(new List <ICluster>()
            {
                mockCluster.Object
            }, 20, 100);

            var allele = nbhd.CandidateVariants.First();

            Assert.Equal(6, allele.TotalCoverage);
            Assert.Equal(6, allele.AlleleSupport);
            Assert.Equal("CGT", allele.Reference);
            Assert.Equal("AAA", allele.Alternate);

            var depths = nbhd.DepthAtSites(new List <ICluster>()
            {
                mockCluster.Object
            });

            Assert.Equal(3, depths.Length);
            Assert.Equal(3, depths[0]);
            Assert.Equal(3, depths[1]);
            Assert.Equal(3, depths[2]);
        }
コード例 #3
0
        public void SetDepthAtSites()
        {
            var nbhd = new VcfNeighborhood(new VariantCallingParameters(), 0, "chr1", new VariantSite(120), new VariantSite(121), "T");

            var vead = PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var vead2 = PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var vead3 = PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var veads = new List <Vead> {
                vead, vead2, vead3
            };
        }
コード例 #4
0
        private Mock <IVeadGroupSource> MockVeadSource()
        {
            var returnVeads = new List <VeadGroup>
            {
                new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new [, ] {
                    { "N", "N" }, { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }
                })),
                new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new [, ] {
                    { "N", "N" }, { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }
                })),
                new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r5", new [, ] {
                    { "N", "N" }, { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }
                })),
            };

            var veadSource = new Mock <IVeadGroupSource>();

            veadSource.Setup(s => s.GetVeadGroups(It.IsAny <VcfNeighborhood>())).Returns(returnVeads);
            return(veadSource);
        }
コード例 #5
0
        public void AddMnvsFromClusters()
        {
            //TODO even with mock cluster this takes too much setting up.
            var nbhd = new VcfNeighborhood(0, "chr1", new VariantSite(120), new VariantSite(121));

            var vead = PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var vead2 = PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var vead3 = PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new[, ] {
                { "C", "A" }, { "G", "A" }, { "T", "A" }
            });
            var veads = new List <Vead> {
                vead, vead2, vead3
            };

            vead.SiteResults[0].VcfReferencePosition = 1;
            vead.SiteResults[1].VcfReferencePosition = 2;
            vead.SiteResults[2].VcfReferencePosition = 3;

            vead2.SiteResults[0].VcfReferencePosition = 1;
            vead2.SiteResults[1].VcfReferencePosition = 2;
            vead2.SiteResults[2].VcfReferencePosition = 3;

            vead3.SiteResults[0].VcfReferencePosition = 1;
            vead3.SiteResults[1].VcfReferencePosition = 2;
            vead3.SiteResults[2].VcfReferencePosition = 3;

            var mockCluster = new Mock <ICluster>();

            mockCluster.Setup(c => c.CountsAtSites).Returns(new[] { 10, 3, 5 });
            var consensus = PhasedVariantTestUtilities.CreateVeadGroup(veads);

            mockCluster.Setup(c => c.GetConsensusSites()).Returns(consensus.SiteResults);
            mockCluster.Setup(c => c.GetVeadGroups()).Returns(new List <VeadGroup>()
            {
                consensus
            });

            var callableNeighborhood = new CallableNeighborhood(nbhd, new VariantCallingParameters());

            callableNeighborhood.NbhdReferenceSequenceSubstring = "CGT";
            callableNeighborhood.CreateMnvsFromClusters(new List <ICluster>()
            {
                mockCluster.Object
            }, 20);

            var allele = callableNeighborhood.CandidateVariants.First();

            Assert.Equal(6, allele.TotalCoverage);
            Assert.Equal(6, allele.AlleleSupport);
            Assert.Equal("CGT", allele.ReferenceAllele);
            Assert.Equal("AAA", allele.AlternateAllele);

            int[] depths  = new int[0];
            int[] nocalls = new int[0];
            callableNeighborhood.DepthAtSites(new List <ICluster>()
            {
                mockCluster.Object
            }, out depths, out nocalls);
            Assert.Equal(3, depths.Length);
            Assert.Equal(3, depths[0]);
            Assert.Equal(3, depths[1]);
            Assert.Equal(3, depths[2]);
        }
コード例 #6
0
        public void ClusterVeadGroups()
        {
            // ----------------------------------------------------
            // Four Ns
            //  - This is from original "FourNs Test"
            // ----------------------------------------------------

            var veads = new List <Vead>()
            {
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new string[2, 2] {
                    { "C", "C" }, { "G", "N" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new string[2, 2] {
                    { "C", "C" }, { "G", "N" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new string[2, 2] {
                    { "C", "C" }, { "G", "N" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r4", new string[2, 2] {
                    { "C", "C" }, { "G", "N" }
                }),
            };

            var veadgroup = PhasedVariantTestUtilities.CreateVeadGroup(veads);

            ExecuteClusteringTest(new List <VeadGroup>()
            {
                veadgroup
            },
                                  new List <List <VeadGroup> >
            {
                new List <VeadGroup> {
                    veadgroup
                }
            }, new List <string>()
            {
                "C>C,G>N"
            }
                                  , 1);


            // ----------------------------------------------------
            // Real Data
            //  - This data is from Sample 129 (original "Sample129Test")
            // ----------------------------------------------------

            veads = new List <Vead>()
            {
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new string[2, 2] {
                    { "A", "G" }, { "N", "N" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new string[2, 2] {
                    { "A", "G" }, { "C", "C" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new string[2, 2] {
                    { "A", "A" }, { "C", "C" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r4", new string[2, 2] {
                    { "A", "G" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r5", new string[2, 2] {
                    { "N", "N" }, { "C", "C" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r6", new string[2, 2] {
                    { "N", "N" }, { "C", "A" }
                }),
            };

            var group1 = new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new string[2, 2] {
                { "A", "G" }, { "N", "N" }
            }));
            var group4 = new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r4", new string[2, 2] {
                { "A", "G" }, { "C", "A" }
            }));
            var group6 = new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r6", new string[2, 2] {
                { "N", "N" }, { "C", "A" }
            }));

            var group2 = new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new string[2, 2] {
                { "A", "G" }, { "C", "C" }
            }));

            var group3 = new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new string[2, 2] {
                { "A", "A" }, { "C", "C" }
            }));
            var group5 = new VeadGroup(PhasedVariantTestUtilities.CreateVeadFromStringArray("r5", new string[2, 2] {
                { "N", "N" }, { "C", "C" }
            }));

            ExecuteClusteringTest(new List <VeadGroup>()
            {
                group1, group2, group3, group4, group5, group6
            },
                                  new List <List <VeadGroup> >
            {
                new List <VeadGroup> {
                    group4, group6, group1
                },
                new List <VeadGroup> {
                    group3, group5
                },
                new List <VeadGroup> {
                    group2
                },
            },
                                  new List <string>()
            {
                "A>G,C>A", "A>G,C>C", "A>A,C>C"
            }
                                  , 1, 0);

            // ----------------------------------------------------
            // Ten grouped reads
            //  - This is from original "10 ReadsTest"
            // ----------------------------------------------------

            group1 = PhasedVariantTestUtilities.CreateVeadGroup(new List <Vead>
            {
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r1", new string[6, 2] {
                    { "N", "N" }, { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r2", new string[6, 2] {
                    { "N", "N" }, { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r5", new string[6, 2] {
                    { "N", "N" }, { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }
                }),
            });
            group2 = PhasedVariantTestUtilities.CreateVeadGroup(new List <Vead>
            {
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r3", new string[6, 2] {
                    { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "N", "N" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r4", new string[6, 2] {
                    { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "N", "N" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r7", new string[6, 2] {
                    { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "N", "N" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r8", new string[6, 2] {
                    { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "N", "N" }, { "C", "A" }
                }),
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r9", new string[6, 2] {
                    { "N", "N" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "N", "N" }, { "C", "A" }
                }),
            });
            group3 = PhasedVariantTestUtilities.CreateVeadGroup(new List <Vead>
            {
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r10", new string[6, 2] {
                    { "C", "A" }, { "C", "A" }, { "C", "A" }, { "C", "A" }, { "N", "N" }, { "C", "A" }
                }),
            });
            group4 = PhasedVariantTestUtilities.CreateVeadGroup(new List <Vead>
            {
                PhasedVariantTestUtilities.CreateVeadFromStringArray("r6", new string[6, 2] {
                    { "C", "C" }, { "C", "C" }, { "C", "C" }, { "C", "C" }, { "C", "C" }, { "C", "C" }
                }),
            });

            ExecuteClusteringTest(new List <VeadGroup>()
            {
                group1, group2, group3, group4
            },
                                  new List <List <VeadGroup> >
            {
                new List <VeadGroup> {
                    group1
                },
                new List <VeadGroup> {
                    group2, group3
                },
                new List <VeadGroup> {
                    group4
                },
            }
                                  , new List <string>()
            {
                "N>N,N>N,C>A,C>A,C>A,C>A", "C>A,C>A,C>A,C>A,N>N,C>A", "C>C,C>C,C>C,C>C,C>C,C>C"
            }, 4, 0);


            ExecuteClusteringTest(new List <VeadGroup>()
            {
                group1, group2, group3, group4
            },
                                  new List <List <VeadGroup> >
            {
                new List <VeadGroup> {
                    group1
                },
                new List <VeadGroup> {
                    group2, group3
                },
                new List <VeadGroup> {
                    group4
                },
            }
                                  , new List <string>()
            {
                "N>N,N>N,C>A,C>A,C>A,C>A", "C>A,C>A,C>A,C>A,N>N,C>A", "C>C,C>C,C>C,C>C,C>C,C>C"
            }, 4, 0,
                                  ploidyConstraint: 3);


            ExecuteClusteringTest(new List <VeadGroup>()
            {
                group1, group2, group3, group4
            },
                                  new List <List <VeadGroup> >
            {
                new List <VeadGroup> {
                    group1
                },                    // 6 reads
                new List <VeadGroup> {
                    group2, group3
                },                           //3 reads
                //new List<VeadGroup>{group4}, //1 reads -> the looser
            }
                                  , new List <string>()
            {
                "N>N,N>N,C>A,C>A,C>A,C>A", "C>A,C>A,C>A,C>A,N>N,C>A", "C>C,C>C,C>C,C>C,C>C,C>C"
            }, 4, 0,
                                  ploidyConstraint: 2);

            ExecuteClusteringTest(new List <VeadGroup>()
            {
                group1, group2, group3, group4
            },
                                  new List <List <VeadGroup> >
            {
                new List <VeadGroup> {
                    group1
                },                    // 6 reads -> the winner
            }
                                  , new List <string>()
            {
                "N>N,N>N,C>A,C>A,C>A,C>A", "C>A,C>A,C>A,C>A,N>N,C>A", "C>C,C>C,C>C,C>C,C>C,C>C"
            }, 4, 0,
                                  ploidyConstraint: 1);
        }