Esempio n. 1
0
        private Uri GetContentsUri(ChorusAccount chorusAccount, ChorusUrl chorusUrl)
        {
            if (chorusUrl.FileId.HasValue)
            {
                return(null);
            }
            if (chorusUrl.ExperimentId.HasValue)
            {
                return(new Uri(chorusUrl.ServerUrl + "/skyline/api/contents/experiments/" + chorusUrl.ExperimentId + "/files")); // Not L10N
            }
            if (chorusUrl.ProjectId.HasValue)
            {
                return(new Uri(chorusUrl.ServerUrl + "/skyline/api/contents/projects/" + chorusUrl.ProjectId + "/experiments")); // Not L10N
            }
            if (!chorusUrl.GetPathParts().Any())
            {
                return(null);
            }
            string           topLevelName     = chorusUrl.GetPathParts().First();
            TopLevelContents topLevelContents = TOP_LEVEL_ITEMS.FirstOrDefault(item => item.Name.Equals(topLevelName));

            if (null != topLevelContents)
            {
                return(new Uri(chorusUrl.ServerUrl + "/skyline/api/contents" + topLevelContents.ContentsPath)); // Not L10N
            }
            return(null);
        }
Esempio n. 2
0
        private IEnumerable <RemoteItem> ListItems(ChorusUrl chorusUrl, ChorusContents chorusContents)
        {
            IEnumerable <RemoteItem> items = new RemoteItem[0];

            if (null != chorusContents.experiments)
            {
                items = items.Concat(chorusContents.experiments.Select(experiment =>
                                                                       new RemoteItem(chorusUrl.SetExperimentId(experiment.id).AddPathPart(experiment.GetName()),
                                                                                      experiment.GetName(), DataSourceUtil.FOLDER_TYPE, null, 0)));
            }
            if (null != chorusContents.files)
            {
                items = items.Concat(chorusContents.files.Select(
                                         file =>
                {
                    ChorusUrl fileUrl = (ChorusUrl)chorusUrl.SetFileId(file.id)
                                        .AddPathPart(file.GetName())
                                        .ChangeRunStartTime(file.GetAcquisitionDateTime())
                                        .ChangeModifiedTime(file.GetModifiedDateTime());
                    return(new RemoteItem(fileUrl, file.GetName(),
                                          GetFileType(file), file.GetModifiedDateTime(), file.fileSizeBytes));
                }
                                         ));
            }
            if (null != chorusContents.projects)
            {
                items = items.Concat(chorusContents.projects.Select(project =>
                                                                    new RemoteItem(chorusUrl.SetProjectId(project.id).AddPathPart(project.GetName()),
                                                                                   project.GetName(), DataSourceUtil.FOLDER_TYPE, null, project.GetSize())));
            }
            return(items);
        }
Esempio n. 3
0
 public ChromatogramGeneratorTask(ChromTaskList chromTaskList, ChorusAccount chorusAccount, ChorusUrl chorusUrl,
                                  ChromatogramRequestDocument chromatogramRequestDocument)
 {
     ChromTaskList = chromTaskList;
     ChorusAccount = chorusAccount;
     ChorusUrl     = chorusUrl;
     ChromatogramRequestDocument = chromatogramRequestDocument;
 }
Esempio n. 4
0
        public ChromatogramRequestProvider(SrmDocument srmDocument, ChorusUrl chorusUrl, IRetentionTimePredictor retentionTimePredictor, bool firstPass)
        {
            _srmDocument            = srmDocument;
            _chorusUrl              = chorusUrl;
            _retentionTimePredictor = retentionTimePredictor;
            _firstPass              = firstPass;
            // Create a SpectrumFilter without an IRetentionTimeProvider in order to get the list of ChromKeys that we will eventually provide.
            SpectrumFilter spectrumFilter = new SpectrumFilter(_srmDocument, _chorusUrl, null, 0);

            _chromKeys = ImmutableList.ValueOf(ListChromKeys(GetChromatogramRequestDocument(spectrumFilter)));
        }
Esempio n. 5
0
        public MsDataSpectrum[] GetSpectra(ChorusUrl chorusUrl, ChromSource source,
                                           SignedMz precursor, int scanId)
        {
            string strSource;
            int    msLevel = 1;

            // ReSharper disable NonLocalizedString
            switch (source)
            {
            case ChromSource.ms1:
                strSource = "ms1";
                break;

            case ChromSource.sim:
                strSource = "sim";
                break;

            case ChromSource.fragment:
                strSource = "ms2";
                msLevel   = 2;
                break;

            default:
                throw new ArgumentException("Unknown source " + source);
            }

            string strUri = string.Format(CultureInfo.InvariantCulture,
                                          "{0}/skyline/api/chroextract-drift/file/{1}/source/{2}/precursor/{3}/{4}",
                                          chorusUrl.ServerUrl,
                                          chorusUrl.FileId,
                                          strSource,
                                          precursor.RawValue, // This will be a negative value for negative ion mode data
                                          scanId);
            // ReSharper restore NonLocalizedString

            var webRequest = (HttpWebRequest)WebRequest.Create(new Uri(strUri));

            AddAuthHeader(ChorusAccount, webRequest);
            return(SendRequest(webRequest, response =>
            {
                string strResponse = string.Empty;
                var responseStream = response.GetResponseStream();
                if (null != responseStream)
                {
                    var streamReader = new StreamReader(responseStream);
                    strResponse = streamReader.ReadToEnd();
                }
                JObject jObject = JsonConvert.DeserializeObject <JObject>(strResponse);
                JArray array = (JArray)jObject["results"];  // Not L10N
                return array.OfType <JObject>().Select(obj => GetSpectrumFromJObject(obj, msLevel)).ToArray();
            }));
        }
Esempio n. 6
0
        public ChorusScanProvider(string docFilePath, ChorusUrl chorusUrl, ChromSource source, IList <float> times,
                                  TransitionFullScanInfo[] transitions)
        {
            ChorusUrl    = chorusUrl;
            DocFilePath  = docFilePath;
            DataFilePath = chorusUrl;
            Source       = source;
            Times        = times;
            Transitions  = transitions;
            ChorusAccount chorusAccount = ChorusUrl.FindChorusAccount(Settings.Default.RemoteAccountList);

            _chorusSession = new ChorusSession(chorusAccount);
        }
Esempio n. 7
0
        public ChromatogramCache GenerateChromatograms(ChorusAccount chorusAccount,
                                                       ChorusUrl chorusUrl,
                                                       ChromatogramRequestDocument chromatogramRequestDocument)
        {
            var webRequest = (HttpWebRequest)WebRequest.Create(chorusUrl.GetChromExtractionUri());

            AddAuthHeader(chorusAccount, webRequest);
            webRequest.Method = "POST"; // Not L10N
            var xmlSerializer = new XmlSerializer(typeof(ChromatogramRequestDocument));

            xmlSerializer.Serialize(webRequest.GetRequestStream(), chromatogramRequestDocument);
            webRequest.GetRequestStream().Close();
            return(SendRequest(webRequest, response =>
            {
                MemoryStream memoryStream = new MemoryStream();
                var responseStream = response.GetResponseStream();
                if (responseStream != null)
                {
                    byte[] buffer = new byte[65536];
                    int count;
                    while ((count = responseStream.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        memoryStream.Write(buffer, 0, count);
                    }
                }
                if (0 == memoryStream.Length)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        throw new IOException(string.Format("Empty response: status = {0}", response.StatusCode)); // Not L10N
                    }
                    Debug.WriteLine("Zero byte response");                                                         // Not L10N
                    return null;
                }
                ChromatogramCache.RawData rawData;
                ChromatogramCache.LoadStructs(memoryStream, out rawData, false);
                var chromCacheFile = rawData.ChromCacheFiles[0];
                rawData.ChromCacheFiles = new[]
                {
                    chromCacheFile.ChangeFilePath(chorusUrl)
                };
                return new ChromatogramCache(string.Empty, rawData,
                                             new ChromatogramGeneratorTask.MemoryPooledStream(memoryStream));
            }));
        }
Esempio n. 8
0
 public ChromTaskList(Action checkCancelledAction, SrmDocument srmDocument, ChorusAccount chorusAccount, ChorusUrl chorusUrl, IEnumerable <ChromatogramRequestDocument> chromatogramRequestDocuments)
 {
     SrmDocument                 = srmDocument;
     ChorusSession               = new ChorusSession(chorusAccount);
     _checkCancelledAction       = checkCancelledAction;
     _chromatogramGeneratorTasks = new List <ChromatogramGeneratorTask>();
     _chromKeys = new Dictionary <ChromKey, ChromatogramGeneratorTask>();
     foreach (var chunk in chromatogramRequestDocuments)
     {
         ChromatogramGeneratorTask task = new ChromatogramGeneratorTask(this, chorusAccount, chorusUrl, chunk);
         _chromatogramGeneratorTasks.Add(task);
         foreach (ChromKey chromKey in ListChromKeys(chunk))
         {
             _chromKeys[chromKey] = task;
         }
     }
     _executingTasks = new HashSet <ChromatogramGeneratorTask>();
 }
Esempio n. 9
0
 protected bool Equals(ChorusUrl other)
 {
     return(base.Equals(other) && ProjectId == other.ProjectId && ExperimentId == other.ExperimentId &&
            FileId == other.FileId && RunStartTime.Equals(other.RunStartTime));
 }