コード例 #1
0
        public ChromosomeIndelSource(List <HashableIndel> indels, IGenomeSnippetSource snippetSource, int bucketSize = 1000)
        {
            _bucketSize = bucketSize;
            Indels      = indels;

            var partnerIndelsLookup = new Dictionary <HashableIndel, IEnumerable <HashableIndel> >();
            var positionalBuckets   = new Dictionary <int, List <HashableIndel> >();
            var snippetsLookup      = new Dictionary <int, GenomeSnippet>();

            if (!indels.Any())
            {
                _partnerIndels             = new ReadOnlyDictionary <HashableIndel, IEnumerable <HashableIndel> >(partnerIndelsLookup);
                _genomeSnippetsLookup      = new ReadOnlyDictionary <int, GenomeSnippet>(snippetsLookup);
                _positionalBucketsOfIndels = new ReadOnlyDictionary <int, List <HashableIndel> >(positionalBuckets);

                return;
            }
            LowestPosition  = indels.Min(x => x.ReferencePosition);
            HighestPosition = indels.Max(x => x.ReferencePosition);


            foreach (var indel in indels)
            {
                var bucketNum = ((indel.ReferencePosition - LowestPosition) / bucketSize);

                if (!positionalBuckets.TryGetValue(bucketNum, out var indelsForbucket))
                {
                    indelsForbucket = new List <HashableIndel>();
                    positionalBuckets.Add(bucketNum, indelsForbucket);
                }

                // TODO come back to this if needed - was thinking I could link indels to each other so that if multi-indels contain indels in multiple buckets we would make sure to grab all
                // Maybe add start and end pos of hashables, and this could take into account the main and the other
                //var indelString = Helper.HashableToString(indel);
                var indelString   = indel.StringRepresentation;
                var partnerIndels = indels.Where(x =>
                                                 x.StringRepresentation == indelString || x.OtherIndel == indelString);
                partnerIndelsLookup.Add(indel, partnerIndels);
                indelsForbucket.Add(indel);
                _numIndels++;
            }

            _partnerIndels = new ReadOnlyDictionary <HashableIndel, IEnumerable <HashableIndel> >(partnerIndelsLookup);

            _positionalBucketsOfIndels = new ReadOnlyDictionary <int, List <HashableIndel> >(positionalBuckets);

            foreach (var kvp in _positionalBucketsOfIndels)
            {
                var bucket = kvp.Value;
                if (bucket.Any())
                {
                    var firstIndel = bucket.First();
                    var snippet    = snippetSource.GetGenomeSnippet(firstIndel.ReferencePosition);

                    snippetsLookup[kvp.Key] = snippet;
                }
            }

            _genomeSnippetsLookup = new ReadOnlyDictionary <int, GenomeSnippet>(snippetsLookup);
        }
コード例 #2
0
 public IChromosomeIndelSource GetChromosomeIndelSource(List <HashableIndel> chromIndels, IGenomeSnippetSource snippetSource)
 {
     return(new ChromosomeIndelSource(chromIndels, snippetSource));
 }
コード例 #3
0
 public NmCalculator(IGenomeSnippetSource genomeSnippetSource)
 {
     _genomeSnippetSource = genomeSnippetSource;
 }
コード例 #4
0
 public ReusableSnippetSource(IGenomeSnippetSource snippetSource, int snippetBuffer = 1000)
 {
     _snippetSource = snippetSource;
     _snippetBuffer = snippetBuffer;
 }