Example #1
0
    public List<PileupCount> Add(SAMAlignedItem item, int count)
    {
      List<PileupCount> result = null;

      if (!item.Locations[0].Seqname.Equals(this.Chromosome))
      {
        result = Count;
        Count = new List<PileupCount>();
      }
      else if (this.Position != -1)
      {
        if (item.Pos > this.Count.Last().Position)
        {
          result = Count;
          Count = new List<PileupCount>();
        }
        else
        {
          int finishedCount = (int)(item.Pos - this.Position);
          if (finishedCount > 0)
          {
            result = new List<PileupCount>();
            result.AddRange(Count.Take(finishedCount));
            Count.RemoveRange(0, finishedCount);
          }
        }
      }

      string align, refer;
      item.GetSequences(out align, out refer);
      for (int i = Count.Count; i < align.Length; i++)
      {
        Count.Add(new PileupCount()
        {
          Chromosome = item.Locations[0].Seqname,
          Position = item.Locations[0].Start + i,
          Reference = refer[i]
        });
      }

      for (int i = 0; i < align.Length; i++)
      {
        var c = align[i];
        var dic = Count[i];
        int curcount = 0;
        if (dic.TryGetValue(c, out curcount))
        {
          dic[c] = curcount + count;
        }
        else
        {
          dic[c] = count;
        }
      }

      return result;
    }
Example #2
0
    public void TestGetGetSequences()
    {
      SAMAlignedItem item = new SAMAlignedItem();
      item.AddLocation(new SAMAlignedLocation(item)
      {
        Cigar = "5S18M2D19M5S",
        Start = 39979942,
        MismatchPositions = "18^CA10T8",
        Sequence = "aaaaaGTAGTACCAACTGTAAGTCCTTATCTTCATACTTTGTaaaaa"
      });

      string align, refer;
      item.GetSequences(out align, out refer);

      Assert.AreEqual("GTAGTACCAACTGTAAGT  CCTTATCTTCATACTTTGT", align);
      Assert.AreEqual("GTAGTACCAACTGTAAGTCACCTTATCTTCTTACTTTGT", refer);
    }
Example #3
0
    public void Add(SAMAlignedItem item, int count)
    {
      string align, refer;
      item.GetSequences(out align, out refer);

      for (int i = 0; i < align.Length; i++)
      {
        var c = align[i];
        var dic = Count[(int)(item.Pos) + i];
        int curcount = 0;
        if (dic.TryGetValue(c, out curcount))
        {
          dic[c] = curcount + count;
        }
        else
        {
          dic[c] = count;
        }
      }
    }