Ejemplo n.º 1
0
        public string GetAnalysisQueryOutput(Guid analysisId, string queryId, string filename)
        {
            var entity = _tableStorageProvider.GetEntity <AnalysisEntity>(AnalysisEntity.AllUsersPk, analysisId.ToString());

            if (entity == null)
            {
                throw new Exception("No such analysis " + analysisId);
            }

            var blobs = _blobStorageProvider.ListBlobs(entity.OutputContainer);

            var blob = blobs.FirstOrDefault(b => b.BlobName == filename);

            if (blob == null)
            {
                throw new Exception("No such query output " + filename);
            }

            return(_blobStorageProvider.GetBlobAsText(entity.OutputContainer, blob.BlobName));
        }
Ejemplo n.º 2
0
        public string GetSearchQueryOutput(Guid searchId, string queryId, string filename)
        {
            var entity = _tableStorageProvider.GetEntity <SearchEntity>(SearchEntity.AllUsersPk, searchId.ToString());

            if (entity == null)
            {
                throw new Exception("No such search " + searchId);
            }

            var blobs = _blobStorageProvider.ListBlobs(entity.OutputContainer);

            var blob = blobs.FirstOrDefault(b => b.BlobName.EndsWith(filename));

            if (blob == null)
            {
                throw new Exception("No such query output " + filename);
            }

            return(_blobStorageProvider.GetBlobAsText(entity.OutputContainer, blob.BlobName));
        }
Ejemplo n.º 3
0
        private DatabaseEntity GetDatabase(string databaseName, IEnumerable <Blob> databaseBlobs)
        {
            var aliasBlobName = GetDatabaseAliasBlobs(databaseBlobs).FirstOrDefault();

            if (aliasBlobName != null)
            {
                var content = _blobStorageProvider.GetBlobAsText(_databaseContainerName, aliasBlobName);
                if (!string.IsNullOrEmpty(content))
                {
                    var alias = DatabaseAlias.FromContent(content);
                    if (!string.IsNullOrEmpty(alias.Title) && alias.Length > 0 && alias.DatabaseList != null)
                    {
                        return(GetDatabaseFromAliasBlob(databaseName, alias, aliasBlobName, databaseBlobs));
                    }
                }
            }

            // Create a db fragment for each file in the segment, e.g. nt.00.nhd, nt.00.nhi,
            // nt.00.nhr, etc.
            var segmentFragments =
                databaseBlobs.Select(
                    blob =>
                    new DatabaseFragment(blob.BlobName, blob.Length));

            var fragments = new List <DatabaseFragment>(segmentFragments);

            if (fragments.Any())
            {
                var type = Path.GetExtension(databaseBlobs.First().BlobName).StartsWith("n")
                    ? DatabaseType.Nucleotide
                    : DatabaseType.Protein;
                var length =
                    fragments.Where(frag => !frag.Filename.EndsWith(".nal") && !frag.Filename.EndsWith(".pal"))
                    .Sum(frag => frag.Size);

                return(new DatabaseEntity(databaseName, ContainerName, fragments.Count, length, DatabaseState.Ready, type));
            }

            return(null);
        }