public void TestMergeExon1() { var item = new MatchedBedItem(); MatchExon e1 = new MatchExon(); e1.TranscriptId = "E1"; e1.Add(new Location(1, 10)); e1.Add(new Location(30, 40)); MatchExon e2 = new MatchExon(); e2.TranscriptId = "E2"; e2.Add(new Location(1, 10)); e2.Add(new Location(30, 40)); MatchExon e3 = new MatchExon(); e3.TranscriptId = "E3"; e3.Add(new Location(30, 39)); item.Exons.Add(e1); item.Exons.Add(e2); item.Exons.Add(e3); Assert.AreEqual(3, item.Exons.Count); item.MergeExon(); Assert.AreEqual(1, item.Exons.Count); Assert.AreEqual("E1;E2", item.Exons[0].TranscriptId); }
public void TestContainLocations() { MatchExon e1 = new MatchExon(); e1.Add(new Location(1, 10)); e1.Add(new Location(30, 40)); var e2 = new[] { new Location(1, 10), new Location(30, 40) }; var e3 = new[] { new Location(1, 11), new Location(30, 40) }; Assert.IsTrue(e1.EqualLocations(e2)); Assert.IsFalse(e1.EqualLocations(e3)); }
public void TestContainLocation() { MatchExon e1 = new MatchExon(); e1.Add(new Location(1, 10)); e1.Add(new Location(30, 40)); Location l1 = new Location(3, 6); Assert.IsTrue(e1.ContainLocation(l1)); Location l2 = new Location(3, 11); Assert.IsFalse(e1.ContainLocation(l2)); Location l3 = new Location(25, 35); Assert.IsFalse(e1.ContainLocation(l3)); }
private MatchExon ParseMatchExon(string[] parts) { MatchExon mx = new MatchExon(); mx.TranscriptId = parts[7]; mx.TranscriptType = parts[8]; mx.TranscriptCount = int.Parse(parts[9]); mx.RetainedIntron = parts[10] == "1"; mx.IntronSize = int.Parse(parts[11]); var exons = parts[13].Split(';'); foreach (var exon in exons) { mx.Add(new Location(exon)); } return mx; }
public void TestEqualLocations() { MatchExon e1 = new MatchExon(); e1.Add(new Location(1, 10)); e1.Add(new Location(30, 40)); MatchExon e2 = new MatchExon(); e2.Add(new Location(1, 10)); e2.Add(new Location(30, 40)); MatchExon e3 = new MatchExon(); e3.Add(new Location(1, 11)); e3.Add(new Location(30, 40)); Assert.IsTrue(e1.EqualLocations(e2)); Assert.IsFalse(e1.EqualLocations(e3)); }
private MatchExon ParseMatchExon(string[] parts) { MatchExon mx = new MatchExon(); mx.TranscriptId = parts[7]; mx.TranscriptType = parts[8]; mx.TranscriptCount = int.Parse(parts[9]); mx.RetainedIntron = parts[10] == "1"; mx.IntronSize = int.Parse(parts[11]); var exons = parts[13].Split(';'); foreach (var exon in exons) { mx.Add(new Location(exon)); } return(mx); }
public void MatchGtfTranscriptItem(GtfTranscriptItem gtItem) { int index = gtItem.FindItemIndex(this.Start, this.End - 1); if (-1 == index) { return; } GtfItem gitem = gtItem[index]; MatchExon exon = new MatchExon(); this.exons.Add(exon); exon.TranscriptId = gitem.TranscriptId; exon.TranscriptCount = 1; exon.TranscriptType = gitem.Source; Location ml = new Location(); exon.Add(ml); if (gitem.Start > this.Start) { //if the peak range is out of the exon range, that peak range may be potential exon which //is detected by RNASeq data, so just extend the peak range to expect length rather than //extend by prior exon range ml.Start = this.ExpectStart; exon.IntronSize = gitem.Start - this.Start; exon.RetainedIntron = true; } else if (gitem.Start <= this.ExpectStart) { //the exon has enough base pair ml.Start = this.ExpectStart; } else { //the exon has no enough base pair ml.Start = gitem.Start; long expectLength = ml.Start - this.ExpectStart; int curindex = index - 1; while (expectLength > 0 && curindex >= 0) { Location lp = new Location(); exon.Insert(0, lp); GtfItem prior = gtItem[curindex]; lp.End = prior.End; if (prior.Length >= expectLength) { lp.Start = prior.End - expectLength + 1; break; } else { lp.Start = prior.Start; expectLength = expectLength - prior.Length; curindex--; } } } if (gitem.End < this.End - 1) { ml.End = this.ExpectEnd; exon.IntronSize = this.End - 1 - gitem.End; exon.RetainedIntron = true; } else if (gitem.End >= this.ExpectEnd) { ml.End = this.ExpectEnd; } else { ml.End = gitem.End; long expectLength = this.ExpectEnd - ml.End; int curindex = index + 1; while (expectLength > 0 && curindex < gtItem.Count) { Location lp = new Location(); exon.Add(lp); GtfItem next = gtItem[curindex]; lp.Start = next.Start; if (next.Length >= expectLength) { lp.End = next.Start + expectLength - 1; break; } else { lp.End = next.End; expectLength = expectLength - next.Length; curindex++; } } } }