private static void WriteGeneralAttributes(TextWriter writer, IRegulatoryRegion regulatoryRegion) { if (!regulatoryRegion.Id.IsEmpty()) { writer.Write($"regulatory_feature_id \"{regulatoryRegion.Id}\"; "); } writer.Write($"regulatory_feature_type \"{regulatoryRegion.Type}\"; "); }
public static IAnnotatedRegulatoryRegion Annotate(IVariant variant, IRegulatoryRegion regulatoryRegion) { var featureEffect = new FeatureVariantEffects(regulatoryRegion, variant.Type, variant, variant.IsStructuralVariant); var consequence = new Consequences(null, featureEffect); consequence.DetermineRegulatoryVariantEffects(); return(new AnnotatedRegulatoryRegion(regulatoryRegion, consequence.GetConsequences())); }
private static void MergeRegulatoryRegion(IRegulatoryRegion previous, IRegulatoryRegion current, RegulatoryRegionComparer comparer) { if (comparer.Equals(previous, current)) { return; } throw new InvalidDataException("Found different regulatory regions"); }
private IRegulatoryRegion[] GetRegulatoryRegions() { var regulatoryRegions = new IRegulatoryRegion[7]; regulatoryRegions[0] = new RegulatoryRegion(_chr17, 100,200,CompactId.Empty, RegulatoryRegionType.enhancer); regulatoryRegions[1] = new RegulatoryRegion(_chr17, 200, 300, CompactId.Empty, RegulatoryRegionType.enhancer); regulatoryRegions[2] = new RegulatoryRegion(_chr17, 300, 400, CompactId.Empty, RegulatoryRegionType.enhancer); regulatoryRegions[3] = new RegulatoryRegion(_chr1, 1000, 2000, CompactId.Empty, RegulatoryRegionType.enhancer); regulatoryRegions[4] = new RegulatoryRegion(_chr1, 2000, 3000, CompactId.Empty, RegulatoryRegionType.enhancer); regulatoryRegions[5] = new RegulatoryRegion(_chr11, 150, 250, CompactId.Empty, RegulatoryRegionType.enhancer); regulatoryRegions[6] = new RegulatoryRegion(_chr11, 250, 350, CompactId.Empty, RegulatoryRegionType.enhancer); return regulatoryRegions; }
public static IAnnotatedRegulatoryRegion Annotate(IVariant variant, IRegulatoryRegion regulatoryRegion) { OverlapType overlapType = Intervals.Utilities.GetOverlapType(regulatoryRegion.Start, regulatoryRegion.End, variant.Start, variant.End); EndpointOverlapType endpointOverlapType = Intervals.Utilities.GetEndpointOverlapType(regulatoryRegion.Start, regulatoryRegion.End, variant.Start, variant.End); var featureEffect = new FeatureVariantEffects(overlapType, endpointOverlapType, false, variant.Type, variant.IsStructuralVariant); var consequence = new Consequences(VariantType.unknown, null, featureEffect); consequence.DetermineRegulatoryVariantEffects(); return(new AnnotatedRegulatoryRegion(regulatoryRegion, consequence.GetConsequences())); }
public TranscriptCacheReaderTests() { var chr1 = new Chromosome("chr1", "1", 0); var chr2 = new Chromosome("chr2", "2", 1); var chr3 = new Chromosome("chr3", "3", 2); _refIndexToChromosome = new Dictionary <ushort, IChromosome> { [chr1.Index] = chr1, [chr2.Index] = chr2, [chr3.Index] = chr3 }; const GenomeAssembly genomeAssembly = GenomeAssembly.GRCh38; var baseHeader = new Header("test", 2, 3, Source.BothRefSeqAndEnsembl, 4, genomeAssembly); var customHeader = new TranscriptCacheCustomHeader(1, 2); _expectedHeader = new CacheHeader(baseHeader, customHeader); var transcriptRegions = new ITranscriptRegion[] { new TranscriptRegion(TranscriptRegionType.Exon, 1, 100, 199, 300, 399), new TranscriptRegion(TranscriptRegionType.Intron, 1, 200, 299, 399, 400), new TranscriptRegion(TranscriptRegionType.Exon, 2, 300, 399, 400, 499) }; var mirnas = new IInterval[2]; mirnas[0] = new Interval(100, 200); mirnas[1] = new Interval(300, 400); var peptideSeqs = new[] { "MASE*" }; var genes = new IGene[1]; genes[0] = new Gene(chr3, 100, 200, true, "TP53", 300, CompactId.Convert("7157"), CompactId.Convert("ENSG00000141510")); var regulatoryRegions = new IRegulatoryRegion[2]; regulatoryRegions[0] = new RegulatoryRegion(chr3, 1200, 1300, CompactId.Convert("123"), RegulatoryRegionType.enhancer); regulatoryRegions[1] = new RegulatoryRegion(chr3, 1250, 1450, CompactId.Convert("456"), RegulatoryRegionType.enhancer); var regulatoryRegionIntervalArrays = regulatoryRegions.ToIntervalArrays(3); var transcripts = GetTranscripts(chr3, genes, transcriptRegions, mirnas); var transcriptIntervalArrays = transcripts.ToIntervalArrays(3); _expectedCacheData = new TranscriptCacheData(_expectedHeader, genes, transcriptRegions, mirnas, peptideSeqs, transcriptIntervalArrays, regulatoryRegionIntervalArrays); }
private static Stream GetCacheStream() { const GenomeAssembly genomeAssembly = GenomeAssembly.GRCh38; var baseHeader = new Header("test", 2, 3, Source.BothRefSeqAndEnsembl, 4, genomeAssembly); var customHeader = new TranscriptCacheCustomHeader(1, 2); var expectedHeader = new CacheHeader(baseHeader, customHeader); var transcriptRegions = new ITranscriptRegion[] { new TranscriptRegion(TranscriptRegionType.Exon, 1, 100, 199, 300, 399), new TranscriptRegion(TranscriptRegionType.Intron, 1, 200, 299, 399, 400), new TranscriptRegion(TranscriptRegionType.Exon, 2, 300, 399, 400, 499) }; var mirnas = new IInterval[2]; mirnas[0] = new Interval(100, 200); mirnas[1] = new Interval(300, 400); var peptideSeqs = new[] { "MASE*" }; var genes = new IGene[1]; genes[0] = new Gene(ChromosomeUtilities.Chr3, 100, 200, true, "TP53", 300, CompactId.Convert("7157"), CompactId.Convert("ENSG00000141510")); var regulatoryRegions = new IRegulatoryRegion[2]; regulatoryRegions[0] = new RegulatoryRegion(ChromosomeUtilities.Chr3, 1200, 1300, CompactId.Convert("123"), RegulatoryRegionType.enhancer); regulatoryRegions[1] = new RegulatoryRegion(ChromosomeUtilities.Chr3, 1250, 1450, CompactId.Convert("456"), RegulatoryRegionType.enhancer); var regulatoryRegionIntervalArrays = regulatoryRegions.ToIntervalArrays(3); var transcripts = GetTranscripts(ChromosomeUtilities.Chr3, genes, transcriptRegions, mirnas); var transcriptIntervalArrays = transcripts.ToIntervalArrays(3); var expectedCacheData = new TranscriptCacheData(expectedHeader, genes, transcriptRegions, mirnas, peptideSeqs, transcriptIntervalArrays, regulatoryRegionIntervalArrays); var ms = new MemoryStream(); using (var writer = new TranscriptCacheWriter(ms, expectedHeader, true)) { writer.Write(expectedCacheData); } ms.Position = 0; return(ms); }
private IRegulatoryRegion[] GetRegulatoryRegions() { var regulatoryRegions = new IRegulatoryRegion[3]; regulatoryRegions[0] = new RegulatoryRegion(_chr11, 11000, 12000, CompactId.Empty, RegulatoryRegionType.promoter); regulatoryRegions[1] = new RegulatoryRegion(_chr1, 120, 180, CompactId.Empty, RegulatoryRegionType.promoter); regulatoryRegions[2] = new RegulatoryRegion(_chr1, 300, 320, CompactId.Empty, RegulatoryRegionType.promoter); return(regulatoryRegions); }
private static IRegulatoryRegion[] GetRegulatoryRegions() { var regulatoryRegions = new IRegulatoryRegion[3]; regulatoryRegions[0] = new RegulatoryRegion(ChromosomeUtilities.Chr11, 11000, 12000, CompactId.Empty, RegulatoryRegionType.promoter); regulatoryRegions[1] = new RegulatoryRegion(ChromosomeUtilities.Chr1, 120, 180, CompactId.Empty, RegulatoryRegionType.promoter); regulatoryRegions[2] = new RegulatoryRegion(ChromosomeUtilities.Chr1, 300, 320, CompactId.Empty, RegulatoryRegionType.promoter); return(regulatoryRegions); }
private static void WriteRegulatoryFeature(TextWriter writer, IRegulatoryRegion regulatoryRegion) { writer.Write($"{regulatoryRegion.Chromosome.UcscName}\t.\tregulatory feature\t{regulatoryRegion.Start}\t{regulatoryRegion.End}\t.\t.\t.\t"); WriteGeneralAttributes(writer, regulatoryRegion); writer.WriteLine(); }
internal void Write(IRegulatoryRegion region) => _writer.WriteLine( $"{region.Chromosome.UcscName}\t{region.Chromosome.Index}\t{region.Start}\t{region.End}\t{region.Id}\t{region.Type}\t{(byte) region.Type}");
public AnnotatedRegulatoryRegion(IRegulatoryRegion regulatoryRegion, List <ConsequenceTag> consequences) { RegulatoryRegion = regulatoryRegion; Consequences = consequences; }