示例#1
0
        public void CosmicOutputTest()
        {
            var sa        = new SupplementaryAnnotationPosition(115256529);
            var saCreator = new SupplementaryPositionCreator(sa);
            var altAllele = "C";

            var cosmicItem1 = new CosmicItem("chr1", 115256529, "COSM1000", "T", altAllele, "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("", "carcinoma", "oesophagus")
            }, 1,
                                             altAllele);

            var cosmicItem2 = new CosmicItem("chr1", 115256529, "COSM1001", "T", altAllele, "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("01", "carcinoma", "large_intestine")
            }, 1,
                                             altAllele);

            cosmicItem1.AddCosmicToSa(saCreator);
            cosmicItem2.AddCosmicToSa(saCreator);

            var saReader = new MockSupplementaryAnnotationReader(sa);

            VcfUtilities.FieldContains(saReader,
                                       "chr1\t115256529\t.\tT\tC\t1000\tPASS\t.\tGT\t0/1", "cosmic=1|COSM1000", VcfCommon.InfoIndex);
        }
示例#2
0
        public void AllSuppAnnotOutputTest()
        {
            const string altAllele = "C";

            var sa = new SupplementaryAnnotationPosition(115256529);

            var oneKg = new OneKGenAnnotation
            {
                OneKgAllAn = 5008,
                OneKgAllAc = 2130,
                OneKgAmrAn = 694,
                OneKgAmrAc = 250
            };

            var dbSnp = new DbSnpAnnotation
            {
                DbSnp = new List <long> {
                    11554290
                }
            };

            var saCreator = new SupplementaryPositionCreator(sa);

            saCreator.AddExternalDataToAsa(DataSourceCommon.DataSource.OneKg, "C", oneKg);
            saCreator.AddExternalDataToAsa(DataSourceCommon.DataSource.DbSnp, "C", dbSnp);

            var cosmicItem1 = new CosmicItem("chr1", 115256529, "COSM1000", "T", altAllele, "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("", "carcinoma", "oesophagus")
            }, 1,
                                             altAllele);

            var cosmicItem2 = new CosmicItem("chr1", 115256529, "COSM1001", "T", altAllele, "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("01", "carcinoma", "large_intestine")
            }, 1,
                                             altAllele);

            cosmicItem1.AddCosmicToSa(saCreator);
            cosmicItem2.AddCosmicToSa(saCreator);

            var clinvarItem1 = new ClinVarItem(null, 0, null, altAllele, null, "RCV001",
                                               null, null, new List <string> {
                "ORPHA2462"
            }, null, null, "other");

            sa.ClinVarItems.Add(clinvarItem1);

            var saReader   = new MockSupplementaryAnnotationReader(sa);
            var infoColumn = VcfUtilities.GetVcfColumn(saReader,
                                                       "chr1\t115256529\t.\tT\tC\t1000\tPASS\t.\tGT\t0/1", VcfCommon.InfoIndex);

            Assert.Contains("AF1000G=0.425319", infoColumn);
            Assert.Contains("cosmic=1|COSM1000,1|COSM1001", infoColumn);
            Assert.Contains("clinvar=1|other", infoColumn);
        }
示例#3
0
        public void GetJsonString()
        {
            var cosmicItem = new CosmicItem(ChromosomeUtilities.Chr1, 100, "rs101", "A", "C", "GENE0", new HashSet <CosmicItem.CosmicStudy>
            {
                new CosmicItem.CosmicStudy("100", new [] { "primary histology 0", "histology subtype 1" }, new [] { "primarySite 0", "site subtype 1" }),
                new CosmicItem.CosmicStudy("101", new [] { "primary histology 0", "histology subtype 2" }, new [] { "primarySite 0", "site subtype 1" })
            }, 1);

            Assert.Equal("\"id\":\"rs101\",\"refAllele\":\"A\",\"altAllele\":\"C\",\"gene\":\"GENE0\",\"sampleCount\":1,\"cancerTypesAndCounts\":[{\"cancerType\":\"primary histology 0\",\"count\":2},{\"cancerType\":\"histology subtype 1\",\"count\":1},{\"cancerType\":\"histology subtype 2\",\"count\":1}],\"cancerSitesAndCounts\":[{\"cancerSite\":\"primarySite 0\",\"count\":2},{\"cancerSite\":\"site subtype 1\",\"count\":2}]", cosmicItem.GetJsonString());
        }
示例#4
0
        public void MergeDbSnpCosmic1Kg()
        {
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";
            const string vcfLine2 = "1	10228	.	TA	T	100	PASS	AC=2130;AF=0.425319;AN=5008;NS=2504;DP=103152;EAS_AF=0.3363;AMR_AF=0.3602;AFR_AF=0.4909;EUR_AF=0.4056;SAS_AF=0.4949;AA=|||unknown(NO_COVERAGE)";

            var sa              = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(10229));
            var dbsnpReader     = new DbSnpReader(_renamer);
            var dbSnpItem1      = dbsnpReader.ExtractItem(vcfLine1)[0];
            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(sa)
            };


            var cosmicItem1 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy(null, "carcinoma", "oesophagus")
            }, null);

            additionalItems.Add(cosmicItem1.SetSupplementaryAnnotations(sa));

            var oneKGenItem = _oneKGenReader.ExtractItems(vcfLine2)[0];

            additionalItems.Add(oneKGenItem.SetSupplementaryAnnotations(sa));

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa);
            }

            var asa   = sa.SaPosition.AlleleSpecificAnnotations["1"];
            var dbSnp = asa.Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as DbSnpAnnotation;
            var oneKg = asa.Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.OneKg)] as OneKGenAnnotation;

            Assert.NotNull(oneKg);

            var oneKgAc = oneKg.OneKgAllAc;
            var oneKgAn = oneKg.OneKgAllAn;

            Assert.NotNull(oneKgAc);
            Assert.NotNull(oneKgAn);

            Assert.NotNull(dbSnp);
            Assert.NotNull(oneKg);
            Assert.Equal(dbSnp.DbSnp, new List <long> {
                143255646
            });
            Assert.Equal("0.425319", (oneKgAc.Value / (double)oneKgAn.Value).ToString(JsonCommon.FrequencyRoundingFormat));

            Assert.True(sa.SaPosition.ContainsCosmicId("COSM1000"));
        }
示例#5
0
        public void EqualityAndHash()
        {
            var cosmicItem = new CosmicItem("chr1", 100, "rs101", "A", "C", "GENE0", new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("100", "histology", "primarySite")
            }, 1);

            var customHash = new HashSet <CosmicItem> {
                cosmicItem
            };

            Assert.Equal(1, customHash.Count);
            Assert.True(customHash.Contains(cosmicItem));
        }
示例#6
0
        public void GetCancerTypeCount_same_study()
        {
            var cosmicItem = new CosmicItem(ChromosomeUtilities.Chr1, 100, "rs101", "A", "C", "GENE0", new HashSet <CosmicItem.CosmicStudy>
            {
                new CosmicItem.CosmicStudy("100", new [] { "primary histology 0", "histology subtype 1" }, new [] { "primarySite 0", "site subtype 1" }),
                new CosmicItem.CosmicStudy("100", new [] { "primary histology 0", "histology subtype 1" }, new [] { "primarySite 0", "site subtype 1" })
            }, 1);

            var cancerTypeCounts = cosmicItem.GetCancerTypeCounts();

            Assert.Equal(2, cancerTypeCounts.Count);
            Assert.Equal(1, cancerTypeCounts["primary histology 0"]);
            Assert.Equal(1, cancerTypeCounts["histology subtype 1"]);
        }
示例#7
0
        public void GetTissueCount_same_study()
        {
            var cosmicItem = new CosmicItem(new Chromosome("chr1", "1", 0), 100, "rs101", "A", "C", "GENE0", new HashSet <CosmicItem.CosmicStudy>
            {
                new CosmicItem.CosmicStudy("100", new [] { "primary histology 0", "histology subtype 1" }, new [] { "primarySite 0", "site subtype 1" }),
                new CosmicItem.CosmicStudy("100", new [] { "primary histology 0", "histology subtype 1" }, new [] { "primarySite 0", "site subtype 1" })
            }, 1);

            var tissueCounts = cosmicItem.GetTissueCounts();

            Assert.Equal(2, tissueCounts.Count());
            Assert.Equal(1, tissueCounts["primarySite 0"]);
            Assert.Equal(1, tissueCounts["site subtype 1"]);
        }
示例#8
0
        public void GetCancerTypeCount_different_studies()
        {
            var cosmicItem = new CosmicItem(new Chromosome("chr1", "1", 0), 100, "rs101", "A", "C", "GENE0", new HashSet <CosmicItem.CosmicStudy>
            {
                new CosmicItem.CosmicStudy("100", new [] { "primary histology 0", "histology subtype 1" }, new [] { "primarySite 0", "site subtype 1" }),
                new CosmicItem.CosmicStudy("101", new [] { "primary histology 0", "histology subtype 2" }, new [] { "primarySite 0", "site subtype 1" })
            }, 1);

            var cancerTypeCounts = cosmicItem.GetCancerTypeCounts();

            Assert.Equal(3, cancerTypeCounts.Count());
            Assert.Equal(2, cancerTypeCounts["primary histology 0"]);
            Assert.Equal(1, cancerTypeCounts["histology subtype 1"]);
            Assert.Equal(1, cancerTypeCounts["histology subtype 2"]);
        }
示例#9
0
        public void MergeDbSnpCosmic()
        {
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";


            var sa              = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(10229));
            var dbsnpReader     = new DbSnpReader(_renamer);
            var dbSnpItem1      = dbsnpReader.ExtractItem(vcfLine1)[0];
            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(sa)
            };

            var cosmicItem1 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy(null, "carcinoma", "oesophagus")
            }, null);
            var cosmicItem2 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("01", "carcinoma", "large_intestine")
            }, null);

            additionalItems.Add(cosmicItem1.SetSupplementaryAnnotations(sa));
            additionalItems.Add(cosmicItem2.SetSupplementaryAnnotations(sa));

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa);
            }

            var dbSnpAnnotation =
                sa.SaPosition.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnpAnnotation);
            Assert.Equal(dbSnpAnnotation.DbSnp, new List <long> {
                143255646
            });
            Assert.True(sa.SaPosition.ContainsCosmicId("COSM1000"));
        }
    private void FillChunk(ChunkCoords c)
    {
        ChunkCoords signedCoords = c;

        signedCoords.ConvertToSignedCoords();
        float amount = Mathf.PerlinNoise(c.x * perlinStretchModifier + perlinOffset.x,
                                         c.y * perlinStretchModifier + perlinOffset.y);

        float min = Mathf.Min(cosmicDensity.x, cosmicDensity.y);
        float max = Mathf.Max(cosmicDensity.x, cosmicDensity.y);

        amount = amount * (max - min) + min;
        for (int i = 0; i < (int)amount; i++)
        {
            Vector3 spawnPos = new Vector3(UnityEngine.Random.Range(0f, EntityNetwork.CHUNK_SIZE),
                                           UnityEngine.Random.Range(0f, EntityNetwork.CHUNK_SIZE),
                                           (1f - Mathf.Pow(UnityEngine.Random.value, 7f * (max / amount))) * starDistanceRange + starMinDistance);
            bool          common           = lessFrequentTypes.Count == 0 || UnityEngine.Random.value <= commonTypeFrequency;
            List <Sprite> listToChooseFrom = common ? types : lessFrequentTypes;
            CosmicItem    newItem          = new CosmicItem((byte)UnityEngine.Random.Range(0, listToChooseFrom.Count), spawnPos,
                                                            UnityEngine.Random.Range(scaleRange.x, scaleRange.y), (byte)UnityEngine.Random.Range(0, 8), common);
            Chunk(c).Add(newItem);
        }
    }
示例#11
0
        public void ReadWriteDbSnpCosmic()
        {
            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // create our expected data source versions
            var dbSnpVersion  = new DataSourceVersion("dbSNP", "142", DateTime.Parse("2015-01-02").Ticks);
            var cosmicVersion = new DataSourceVersion("COSMIC", "GRCh37_v71", DateTime.Parse("2014-10-21").Ticks);

            var expectedDataSourceVersions = new List <DataSourceVersion> {
                dbSnpVersion, cosmicVersion
            };

            // create our expected supplementary annotations
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";

            var sa        = new SupplementaryAnnotationPosition(10229);
            var saCreator = new SupplementaryPositionCreator(sa);

            var dbsnpReader     = new DbSnpReader(_renamer);
            var dbSnpItem1      = dbsnpReader.ExtractItem(vcfLine1)[0];
            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(saCreator)
            };

            var cosmicItem1 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("", "carcinoma", "oesophagus")
            }, null);
            var cosmicItem2 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("01", "carcinoma", "large_intestine")
            }, null);

            additionalItems.Add(cosmicItem1.SetSupplementaryAnnotations(saCreator));
            additionalItems.Add(cosmicItem2.SetSupplementaryAnnotations(saCreator));

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(saCreator);
            }

            Assert.Equal(1, sa.CosmicItems.Count);
            // the preceeding code has been unit tested in  MergeDbSnpCosmic()

            // write the supplementary annotation file
            using (var writer = new SupplementaryAnnotationWriter(randomPath, "chr1", expectedDataSourceVersions))
            {
                writer.Write(saCreator, sa.ReferencePosition);
            }

            // read the supplementary annotation file
            using (var reader = new SupplementaryAnnotationReader(randomPath))
            {
                // extract the three annotations
                var observedAnnotation1 = reader.GetAnnotation(10229) as SupplementaryAnnotationPosition;
                Assert.NotNull(observedAnnotation1);

                var expDbSnp =
                    sa.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                    DbSnpAnnotation;
                Assert.NotNull(expDbSnp);
                var obsDbSnp =
                    observedAnnotation1.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                    DbSnpAnnotation;
                Assert.NotNull(obsDbSnp);

                Assert.Equal(expDbSnp.DbSnp, obsDbSnp.DbSnp);
                Assert.True(observedAnnotation1.ContainsCosmicId(sa.CosmicItems[0].ID));
                Assert.Equal(1, observedAnnotation1.CosmicItems.Count);
            }

            File.Delete(randomPath);
            File.Delete(randomPath + ".idx");
        }
    private void SetUpScenery(ChunkCoords cc, ChunkCoords loopedCoords)
    {
        ChunkCoords c        = ChunkCoords.ConvertToUpRight(cc);
        Vector2     chunkPos = new Vector2(c.x * EntityNetwork.CHUNK_SIZE,
                                           c.y * EntityNetwork.CHUNK_SIZE);

        for (int i = 0; i < Chunk(loopedCoords).Count; i++)
        {
            CosmicItem item = Chunk(loopedCoords)[i];
            StarFieldMaterialPropertyManager sfmpm;
            SpriteRenderer rend;
            Transform      tr;
            GameObject     obj;

            if (transitionActive.Count > 0)
            {
                int last = transitionActive.Count - 1;
                sfmpm = transitionActive[last];
                transitionActive.RemoveAt(last);
                rend = sfmpm.rend;
                tr   = sfmpm.transform;
                obj  = sfmpm.obj;
            }
            else
            {
                sfmpm = GetFromPool();
                rend  = sfmpm.rend;
                tr    = sfmpm.transform;
                obj   = sfmpm.obj;
            }

            Vector3 itemPos = item.pos + (Vector3)chunkPos;
            tr.position = itemPos;
            List <Sprite> listToUse = item.common ? types : lessFrequentTypes;
            if (item.type >= listToUse.Count)
            {
                Debug.Log($"Is common? {item.common}. List size: {listToUse.Count}. Item value: {item.type}.", obj);
            }
            else
            {
                rend.sprite = item.common ? types[item.type] : lessFrequentTypes[item.type];
            }
            //Color col = transparent ? nebulaFadeBackground : Color.white;
            Color col = Color.white;
            if (fadeBasedOnDistance)
            {
                float delta = (1f - (item.pos.z - starMinDistance) / starDistanceRange) * 0.9f + 0.1f;
                if (item.common)
                {
                    col.a *= delta;
                }
                else
                {
                    col = Color.Lerp(Color.black, Color.white,
                                     Mathf.Clamp(delta, imageBrightnessRange.x, imageBrightnessRange.y));
                }
            }
            sfmpm.SetColor(col);
            active.Add(sfmpm);
            tr.localScale.Set(item.size, item.size, 1f);
            tr.eulerAngles.Set(0f, 0f, item.rotation * 45f);
            sfmpm.coord = cc;
        }

        transitionActive.ForEach(t => t.rend.enabled = false);
        pool.AddRange(transitionActive);
        transitionActive.Clear();
    }