public IEnumerable <ISupplementaryInterval> GetSupplementaryIntervals(IChromosomeRenamer renamer) { if (_intervalsPosition == -1) { return(null); } var returnPosition = _stream.Position; _stream.Position = _intervalsPosition; var count = _reader.ReadInt32(); // how many supplementary intervals to read if (count == 0) { return(null); } var intervalList = new List <SupplementaryInterval>(count); for (var i = 0; i < count; i++) { intervalList.Add(SupplementaryInterval.Read(_reader, renamer)); } _stream.Position = returnPosition; return(intervalList); }
public void Load(string ucscReferenceName, IChromosomeRenamer renamer) { if (_customAnnotationDirs == null || _customAnnotationDirs.Count == 0 || ucscReferenceName == _currentUcscReferenceName) { return; } _customAnnotationReaders = SupplementaryAnnotationCommon.GetReaders(_customAnnotationDirs, ucscReferenceName); _hasCustomAnnotations = _customAnnotationReaders.Count > 0; _currentUcscReferenceName = ucscReferenceName; }
public void Load(string ucscReferenceName, IChromosomeRenamer renamer) { if (_ciDirs.Count == 0 || ucscReferenceName == _currentUcscReferenceName) { return; } var intervals = GetIntervals(ucscReferenceName); _intervalForest = IntervalArrayFactory.CreateIntervalArray(intervals, renamer); _hasIntervals = !(_intervalForest is NullIntervalSearch <ICustomInterval>); _currentUcscReferenceName = ucscReferenceName; }
public void Load(string ucscReferenceName, IChromosomeRenamer renamer) { if (string.IsNullOrEmpty(_saDir) || ucscReferenceName == _currentUcscReferenceName) { return; } var saPath = Path.Combine(_saDir, ucscReferenceName + ".nsa"); _saReader = File.Exists(saPath) ? new SupplementaryAnnotationReader(saPath) : null; _intervalForest = _saReader?.GetIntervalForest(renamer); _hasIntervals = !(_intervalForest is NullIntervalSearch <ISupplementaryInterval>); _currentUcscReferenceName = ucscReferenceName; }
// constructor public SupplementaryInterval(int start, int end, string refName, string altAllele, VariantType variantType, string source, IChromosomeRenamer renamer, Dictionary <string, int> intValues = null, Dictionary <string, double> doubleValues = null, Dictionary <string, double> freqValues = null, Dictionary <string, string> stringValues = null, List <string> boolValues = null, Dictionary <string, IEnumerable <string> > stringLists = null) : base(start, end) { Start = start; End = end; AlternateAllele = altAllele; VariantType = variantType; Source = source; _intValues = intValues ?? new Dictionary <string, int>(); _boolList = boolValues ?? new List <string>(); _doubleValues = doubleValues ?? new Dictionary <string, double>(); _freqValues = freqValues ?? new Dictionary <string, double>(); _stringValues = stringValues ?? new Dictionary <string, string>(); _stringLists = stringLists ?? new Dictionary <string, IEnumerable <string> >(); ReferenceName = renamer.GetEnsemblReferenceName(refName); }
public static IIntervalForest <ISupplementaryInterval> CreateIntervalArray( IEnumerable <ISupplementaryInterval> intervals, IChromosomeRenamer renamer) { if (intervals == null) { return(new NullIntervalSearch <ISupplementaryInterval>()); } var numRefSeqs = renamer.NumRefSeqs; var intervalLists = new List <IntervalArray <ISupplementaryInterval> .Interval> [numRefSeqs]; for (var i = 0; i < numRefSeqs; i++) { intervalLists[i] = new List <IntervalArray <ISupplementaryInterval> .Interval>(); } foreach (var interval in intervals) { ushort index = renamer.GetReferenceIndex(interval.ReferenceName); if (index == ChromosomeRenamer.UnknownReferenceIndex) { continue; } intervalLists[index].Add(new IntervalArray <ISupplementaryInterval> .Interval(interval.Start, interval.End, interval)); } // create the interval arrays var refIntervalArrays = new IntervalArray <ISupplementaryInterval> [numRefSeqs]; for (var i = 0; i < numRefSeqs; i++) { var sortedIntervals = intervalLists[i].OrderBy(x => x.Begin).ThenBy(x => x.End).ToArray(); refIntervalArrays[i] = new IntervalArray <ISupplementaryInterval>(sortedIntervals); } return(new IntervalForest <ISupplementaryInterval>(refIntervalArrays)); }
public static SupplementaryInterval Read(ExtendedBinaryReader reader, IChromosomeRenamer renamer) { var referenceName = reader.ReadAsciiString(); var start = reader.ReadOptInt32(); var end = reader.ReadOptInt32(); var alternateAllele = reader.ReadAsciiString(); var sequenceAlteration = (VariantType)reader.ReadByte(); var source = reader.ReadAsciiString(); // strings var count = reader.ReadOptInt32(); var stringValues = new Dictionary <string, string>(count); for (var i = 0; i < count; i++) { var key = reader.ReadAsciiString(); var value = reader.ReadAsciiString(); stringValues[key] = value; } // integers count = reader.ReadOptInt32(); var intValues = new Dictionary <string, int>(count); for (var i = 0; i < count; i++) { var key = reader.ReadAsciiString(); var value = reader.ReadOptInt32(); intValues[key] = value; } // booleans count = reader.ReadOptInt32(); var boolList = new List <string>(count); for (var i = 0; i < count; i++) { boolList.Add(reader.ReadAsciiString()); } // doubles count = reader.ReadOptInt32(); var doubleValues = new Dictionary <string, double>(count); for (var i = 0; i < count; i++) { var key = reader.ReadAsciiString(); var value = reader.ReadOptDouble(); doubleValues[key] = value; } // frequencies count = reader.ReadOptInt32(); var freqValues = new Dictionary <string, double>(count); for (var i = 0; i < count; i++) { var key = reader.ReadAsciiString(); var value = reader.ReadOptDouble(); freqValues[key] = value; } //stringLists count = reader.ReadOptInt32(); var stringLists = new Dictionary <string, IEnumerable <string> >(count); for (var i = 0; i < count; i++) { var key = reader.ReadAsciiString(); var valueCount = reader.ReadOptInt32(); var values = ReadStringLists(reader, valueCount); stringLists[key] = values; } return(new SupplementaryInterval(start, end, referenceName, alternateAllele, sequenceAlteration, source, renamer, intValues, doubleValues, freqValues, stringValues, boolList, stringLists)); }
public IIntervalForest <ISupplementaryInterval> GetIntervalForest(IChromosomeRenamer renamer) { return(IntervalArrayFactory.CreateIntervalArray(GetSupplementaryIntervals(renamer), renamer)); }
public void Load(string ucscReferenceName, IChromosomeRenamer renamer) { }
public IEnumerable <ISupplementaryInterval> GetSupplementaryIntervals(IChromosomeRenamer renamer) { throw new NotImplementedException(); }
public IIntervalForest <ISupplementaryInterval> GetIntervalForest(IChromosomeRenamer renamer) { return(new NullIntervalSearch <ISupplementaryInterval>()); }