Ejemplo n.º 1
0
        /// <summary>
        /// constructor
        /// </summary>
        private CacheFile(string path, ushort refIndex, TranscriptDataSource ds, MiniCacheType type, IUpdater updater)
        {
            CachePath            = path;
            TranscriptDataSource = ds;
            Type           = type;
            ReferenceIndex = refIndex;
            Updater        = updater;

            AddInputFiles(FileOperations.GetFullPathWithoutExtension(path));
        }
Ejemplo n.º 2
0
        private static CacheFile TryMatchFilename(string ndbPath, Func <string, Match> matcher, MiniCacheType type,
                                                  ChromosomeRenamer renamer)
        {
            string filename = Path.GetFileName(ndbPath);

            if (filename == null)
            {
                return(null);
            }

            var match = matcher(filename);

            if (!match.Success)
            {
                return(null);
            }

            IUpdater updater;
            string   id, transcriptDataSource;
            int      position;
            ushort   refIndex;

            switch (type)
            {
            case MiniCacheType.Transcript:
                var tuple = FormatUtilities.SplitVersion(match.Groups[1].Value);
                id                   = tuple.Item1;
                refIndex             = renamer.GetReferenceIndex(match.Groups[2].Value);
                transcriptDataSource = match.Groups[3].Value;
                updater              = new TranscriptUpdater(id, refIndex, transcriptDataSource);
                break;

            case MiniCacheType.Regulatory:
                id                   = match.Groups[1].Value;
                refIndex             = renamer.GetReferenceIndex(match.Groups[2].Value);
                transcriptDataSource = match.Groups[3].Value;
                updater              = new RegulatoryUpdater(id, refIndex, transcriptDataSource);
                break;

            case MiniCacheType.Position:
                refIndex = renamer.GetReferenceIndex(match.Groups[1].Value);
                position = int.Parse(match.Groups[2].Value);
                string refAllele = match.Groups[3].Value;
                string altAllele = match.Groups[4].Value;
                transcriptDataSource = match.Groups[5].Value;
                updater = new PositionUpdater(refIndex, position, refAllele, altAllele, transcriptDataSource);
                break;

            case MiniCacheType.PositionRange:
                refIndex = renamer.GetReferenceIndex(match.Groups[1].Value);
                position = int.Parse(match.Groups[2].Value);
                int endPosition = int.Parse(match.Groups[3].Value);
                transcriptDataSource = match.Groups[4].Value;
                updater = new PositionRangeUpdater(refIndex, position, endPosition, transcriptDataSource);
                break;

            default:
                throw new GeneralException($"Unexpected mini-cache type encountered: {type}");
            }

            return(new CacheFile(ndbPath, updater.RefIndex, ConvertTranscriptDataSource(updater.TranscriptDataSource),
                                 type, updater));
        }