Esempio n. 1
0
        private Dictionary <MappedMirnaGroup, PairedMiRNAGroup> FindSimilar(List <MappedMirnaGroup> refmap, List <MappedMirnaGroup> sammap)
        {
            var result = new Dictionary <MappedMirnaGroup, PairedMiRNAGroup>();

            foreach (var refitem in refmap)
            {
                var refseq = refitem[0].Sequence;

                var samples = (from samitem in sammap
                               let combined = MirnaUtils.GetCombinedSequence(refseq, samitem[0].Sequence)
                                              select new { Combined = combined, Item = samitem })
                              .GroupBy(m => m.Combined.MismatchPositions.Length)
                              .ToList()
                              .OrderBy(m => m.Key)
                              .First().ToList();

                if (samples.First().Combined.MismatchPositions.Length > refseq.Length * 0.4)
                {
                    result[refitem] = new PairedMiRNAGroup()
                    {
                        RefItems      = new HashSet <MappedMirnaGroup>(new[] { refitem }),
                        SamItems      = new HashSet <MappedMirnaGroup>(),
                        MismatchCount = int.MaxValue
                    };
                }
                else
                {
                    result[refitem] = new PairedMiRNAGroup()
                    {
                        RefItems      = new HashSet <MappedMirnaGroup>(new[] { refitem }),
                        SamItems      = new HashSet <MappedMirnaGroup>(samples.ConvertAll(m => m.Item)),
                        MismatchCount = samples.First().Combined.MismatchPositions.Length
                    };
                }
            }
            return(result);
        }
    private Dictionary<MappedMirnaGroup, PairedMiRNAGroup> FindSimilar(List<MappedMirnaGroup> refmap, List<MappedMirnaGroup> sammap)
    {
      var result = new Dictionary<MappedMirnaGroup, PairedMiRNAGroup>();
      foreach (var refitem in refmap)
      {
        var refseq = refitem[0].Sequence;

        var samples = (from samitem in sammap
                       let combined = MirnaUtils.GetCombinedSequence(refseq, samitem[0].Sequence)
                       select new { Combined = combined, Item = samitem })
                   .GroupBy(m => m.Combined.MismatchPositions.Length)
                   .ToList()
                   .OrderBy(m => m.Key)
                   .First().ToList();

        if (samples.First().Combined.MismatchPositions.Length > refseq.Length * 0.4)
        {
          result[refitem] = new PairedMiRNAGroup()
          {
            RefItems = new HashSet<MappedMirnaGroup>(new[] { refitem }),
            SamItems = new HashSet<MappedMirnaGroup>(),
            MismatchCount = int.MaxValue
          };
        }
        else
        {
          result[refitem] = new PairedMiRNAGroup()
          {
            RefItems = new HashSet<MappedMirnaGroup>(new[] { refitem }),
            SamItems = new HashSet<MappedMirnaGroup>(samples.ConvertAll(m => m.Item)),
            MismatchCount = samples.First().Combined.MismatchPositions.Length
          };
        }
      }
      return result;
    }