public void IsProximal() { var variantSite1 = new VariantSite(123); var variantSite2 = new VariantSite(126); // Must be less than phasing distance Assert.True(NeighborhoodBuilder.IsProximal(variantSite1, variantSite2, 4)); Assert.False(NeighborhoodBuilder.IsProximal(variantSite1, variantSite2, 3)); // Works both ways Assert.True(NeighborhoodBuilder.IsProximal(variantSite1, variantSite2, 4)); Assert.False(NeighborhoodBuilder.IsProximal(variantSite1, variantSite2, 3)); }
protected override void Context() { base.Context(); var drugMoleculeBuilder = createMoleculeBuilder("Drug"); var localParameterWithCondition = DomainHelperForSpecs.ConstantParameterWithValue(3) .WithName("LocalParameterWithCondition") .WithMode(ParameterBuildMode.Local) .WithParentContainer(drugMoleculeBuilder); localParameterWithCondition.ContainerCriteria = Create.Criteria(x => x.With("Cell")); _molecules = new MoleculeBuildingBlock { drugMoleculeBuilder, createMoleculeBuilder("Other") }; _spatialStructure = new SpatialStructure { NeighborhoodsContainer = new Container().WithName(Constants.NEIGHBORHOODS), GlobalMoleculeDependentProperties = new Container() }; _globalParameter = new Parameter().WithName("GlobalMoleculeParameter").WithFormula(new ConstantFormula(2)); _spatialStructure.GlobalMoleculeDependentProperties.Add(_globalParameter); var topContainer = new Container().WithName("Organism"); var organ = new Container().WithName("Organ").WithParentContainer(topContainer); var cell = new Container().WithName("Cell").WithParentContainer(organ).WithMode(ContainerMode.Physical); var interstitial = new Container().WithName("Interstitial").WithParentContainer(organ).WithMode(ContainerMode.Physical); var mp = new Container().WithName(Constants.MOLECULE_PROPERTIES).WithParentContainer(organ); new Parameter().WithName("Local").WithFormula(new ConstantFormula(3)).WithParentContainer(mp); _spatialStructure.AddTopContainer(topContainer); var neighborhood = new NeighborhoodBuilder().WithName("A2B"); var nmp = new Container().WithName(Constants.MOLECULE_PROPERTIES).WithParentContainer(neighborhood); new Parameter().WithName("Hallo").WithFormula(new ConstantFormula(4)).WithParentContainer(nmp); _spatialStructure.AddNeighborhood(neighborhood); }
protected override void Context() { base.Context(); var n1 = new NeighborhoodBuilder().WithName("cell2int"); var n2 = new NeighborhoodBuilder().WithName("cell2int"); var tc1 = new Container().WithName("Root"); var cell1 = new Container().WithName("Cell").WithParentContainer(tc1); var int1 = new Container().WithName("int").WithParentContainer(tc1); n1.FirstNeighbor = cell1; n1.SecondNeighbor = int1; var tc2 = new Container().WithName("Root"); var cell2 = new Container().WithName("Cell").WithParentContainer(tc2); var int2 = new Container().WithName("int").WithParentContainer(tc2); n2.FirstNeighbor = cell2; n2.SecondNeighbor = int2; _object1 = n1; _object2 = n2; }
protected override void Context() { base.Context(); _molecules = new MoleculeBuildingBlock(); _molecules.Add(createMoleculeBuilder("Drug")); _molecules.Add(createMoleculeBuilder("Other")); _spatialStrcuture = new SpatialStructure(); _spatialStrcuture.NeighborhoodsContainer = new Container().WithName(Constants.NEIGHBORHOODS); _spatialStrcuture.GlobalMoleculeDependentProperties = new Container(); _globalParameter = new Parameter().WithName("GlobalMoleculeParameter").WithFormula(new ConstantFormula(2)); _spatialStrcuture.GlobalMoleculeDependentProperties.Add(_globalParameter); var topcontainer = new Container().WithName("Organism"); var organ = new Container().WithName("Organ").WithParentContainer(topcontainer); var mp = new Container().WithName(Constants.MOLECULE_PROPERTIES).WithParentContainer(organ); new Parameter().WithName("Local").WithFormula(new ConstantFormula(3)).WithParentContainer(mp); _spatialStrcuture.AddTopContainer(topcontainer); var neighborhood = new NeighborhoodBuilder().WithName("A2B"); var nmp = new Container().WithName(Constants.MOLECULE_PROPERTIES).WithParentContainer(neighborhood); new Parameter().WithName("Hallo").WithFormula(new ConstantFormula(4)).WithParentContainer(nmp); _spatialStrcuture.AddNeighborhood(neighborhood); }
public void CreateCallableNbhdsTests() { var vcfFilePath = Path.Combine(TestPaths.LocalTestDataDirectory, "VeryMutated.genome.vcf"); var variantSource = new AlleleReader(vcfFilePath); var vcfNeighborhood = new VcfNeighborhood(0, "chr1", new VariantSite(123), new VariantSite(125)); List <VcfNeighborhood> VcfNeighborhoods = new List <VcfNeighborhood>() { vcfNeighborhood }; //Test 1, genome is NULL var neighborhoodBuilder = new NeighborhoodBuilder(new PhasableVariantCriteria(), new VariantCallingParameters(), variantSource, null, 20); var neighborhoods = neighborhoodBuilder.ConvertToCallableNeighborhoods(VcfNeighborhoods); Assert.Equal(1, neighborhoods.Count()); Assert.Equal(2, neighborhoods.First().VcfVariantSites.Count()); Assert.Equal("chr1", neighborhoods[0].ReferenceName); Assert.Equal("RRR", neighborhoods[0].NbhdReferenceSequenceSubstring); //Test 2, genome is exists, but doesnt have the right chr var genomePath = Path.Combine(TestPaths.SharedGenomesDirectory, "Bacillus_cereus", "Sequence", "WholeGenomeFasta"); var refName = "chr_wrong"; Genome genome = new Genome(genomePath, new List <string>() { refName }); ChrReference chrReference = genome.GetChrReference(refName); neighborhoodBuilder = new NeighborhoodBuilder(new PhasableVariantCriteria(), new VariantCallingParameters(), variantSource, genome, 20); neighborhoods = neighborhoodBuilder.ConvertToCallableNeighborhoods(VcfNeighborhoods); Assert.Equal(1, neighborhoods.Count()); Assert.Equal(2, neighborhoods.First().VcfVariantSites.Count()); Assert.Equal("chr1", neighborhoods[0].ReferenceName); Assert.Equal("RRR", neighborhoods[0].NbhdReferenceSequenceSubstring); //Test 3, genome is exists, and DOES have the right chr refName = "chr"; genome = new Genome(genomePath, new List <string>() { refName }); chrReference = genome.GetChrReference(refName); neighborhoodBuilder = new NeighborhoodBuilder(new PhasableVariantCriteria(), new VariantCallingParameters(), variantSource, genome, 20); vcfNeighborhood = new VcfNeighborhood(0, "chr", new VariantSite(123), new VariantSite(125)); VcfNeighborhoods = new List <VcfNeighborhood>() { vcfNeighborhood }; neighborhoods = neighborhoodBuilder.ConvertToCallableNeighborhoods(VcfNeighborhoods); Assert.Equal(1, neighborhoods.Count()); Assert.Equal(2, neighborhoods.First().VcfVariantSites.Count()); Assert.Equal("chr", neighborhoods[0].ReferenceName); Assert.Equal("TAT", neighborhoods[0].NbhdReferenceSequenceSubstring); }