public SampleParam(Sample[] samples, bool reduced, CVLookUp cv, string name = null)
     : base(name)
 {
     _reduced = reduced;
     _cv = cv;
     _count = samples == null ? 0 : samples.Length;
     Value = samples;
     Default = samples;
 }
        public SamplePanel(Sample[] value, bool variable, CVLookUp cv)
        {
            _variable = variable;
            _cv = cv;
            _count = value == null ? 0 : value.Length;

            InitializeComponent();

            Value = value;
        }
 private string SampleToString(Sample sample)
 {
     return string.Format("sample[{0}] {1}", sample.Id.ToString("00"), sample.Description);
 }
 public void AddSample(Sample sample)
 {
     if (sampleMap.ContainsKey(sample.Id)){
         return;
     }
     sampleMap.Add(sample.Id, sample);
 }
 public void AddSample(int pid, Sample sample)
 {
     sampleMap.Add(pid, sample);
 }
Beispiel #6
0
 public bool AddStudyVariableSample(int id, Sample sample)
 {
     StudyVariable studyVariable;
     if (!_studyVariableMap.ContainsKey(id)){
         studyVariable = new StudyVariable(id);
         studyVariable.AddSample(sample.Id, sample);
         _studyVariableMap.Add(id, studyVariable);
         return true;
     }
     studyVariable = _studyVariableMap[id];
     studyVariable.AddSample(sample.Id, sample);
     return true;
 }
Beispiel #7
0
        public bool AddSampleTissue(int id, Param tissue)
        {
            Sample sample;
            if (!_sampleMap.ContainsKey(id)){
                sample = new Sample(id);
                sample.AddTissue(tissue);
                _sampleMap.Add(id, sample);
                return true;
            }
            sample = _sampleMap[id];

            sample.AddTissue(tissue);
            return true;
        }
Beispiel #8
0
        public bool AddSampleSpecies(int id, Param species)
        {
            Sample sample;
            if (!_sampleMap.ContainsKey(id)){
                sample = new Sample(id);
                sample.AddSpecies(species);
                _sampleMap.Add(id, sample);
                return true;
            }
            sample = _sampleMap[id];

            sample.AddSpecies(species);
            return true;
        }
Beispiel #9
0
 public bool AddSampleDescription(int id, string description)
 {
     Sample sample;
     if (!_sampleMap.ContainsKey(id)){
         sample = new Sample(id){Description = description};
         _sampleMap.Add(id, sample);
         return true;
     }
     sample = _sampleMap[id];
     sample.Description = description;
     return true;
 }
Beispiel #10
0
 public bool AddSampleCustom(int id, Param custom)
 {
     Sample sample;
     if (!_sampleMap.ContainsKey(id)){
         sample = new Sample(id);
         sample.AddCustom(custom);
         _sampleMap.Add(id, sample);
         return true;
     }
     sample = _sampleMap[id];
     sample.AddCustom(custom);
     return true;
 }
Beispiel #11
0
        public bool AddSampleCellType(int id, Param cellType)
        {
            Sample sample;
            if (!_sampleMap.ContainsKey(id)){
                sample = new Sample(id);
                sample.AddCellType(cellType);
                _sampleMap.Add(id, sample);
                return true;
            }
            sample = _sampleMap[id];

            if (sample.CellTypeList.Contains(cellType)){
                return false;
            }

            sample.AddCellType(cellType);
            return true;
        }
Beispiel #12
0
 public void AddSample(Sample sample)
 {
     if (sample == null){
         throw new Exception("Sample should not be null");
     }
     _sampleMap.Add(sample.Id, sample);
 }
Beispiel #13
0
 public bool AddAssaySample(int id, Sample sample)
 {
     Assay assay;
     if (!_assayMap.ContainsKey(id)){
         assay = new Assay(id){Sample = sample};
         _assayMap.Add(id, assay);
         return true;
     }
     assay = _assayMap[id];
     assay.Sample = sample;
     return true;
 }
        protected void GetExperminetValues(IMatrixData summary, IMatrixData experimentalDesignTemplate,
                                           IMatrixData experiment, IMatrixData spectraRef, ref List<MsRunImpl> msruns,
                                           ref List<StudyVariable> studyvariables, ref List<Assay> assays,
                                           ref List<Sample> samples, ref List<Instrument> instruments)
        {
            if (msruns == null) {
                msruns = new List<MsRunImpl>();
            }

            if (studyvariables == null) {
                studyvariables = new List<StudyVariable>();
            }

            if (assays == null) {
                assays = new List<Assay>();
            }

            if (samples == null) {
                samples = new List<Sample>();
            }

            if (instruments == null) {
                instruments = new List<Instrument>();
            }

            #region parse experiment

            if (experiment != null) {
                int studyvarIndex = experiment.StringColumnNames.IndexOf(MetadataElement.STUDY_VARIABLE.Name);
                int assayIndex = experiment.StringColumnNames.IndexOf(MetadataElement.ASSAY.Name);
                int msrunIndex = experiment.StringColumnNames.IndexOf(MetadataElement.MS_RUN.Name);
                int sampleIndex = experiment.StringColumnNames.IndexOf(MetadataElement.SAMPLE.Name);

                Regex sampleRegex = new Regex(@"^([^\[]+) <([^;]*);([^;]*);([^;]*);([^;]*)>");
                Regex runRegex = new Regex(@"^([^\[]+) <([^;]*);([^;]*);([^;]*);([^;]*)>");
                Regex assayRegex = new Regex(@"^([^\[]+) <([^>]*)>");

                for (int row = 0; row < experiment.RowCount; row++) {
                    string studyvariableDescription = experiment.StringColumns[studyvarIndex][row];
                    string assayReagent = experiment.StringColumns[assayIndex][row];
                    string msrunText = experiment.StringColumns[msrunIndex][row];
                    string sampleDescription = experiment.StringColumns[sampleIndex][row];
                    Lib.Model.Param specie = null;
                    Lib.Model.Param tissue = null;
                    Lib.Model.Param cellType = null;
                    Lib.Model.Param disease = null;
                    IList<Lib.Model.Param> mod = new List<Lib.Model.Param>();

                    if (sampleDescription != null && sampleRegex.IsMatch(sampleDescription)) {
                        var match = sampleRegex.Match(sampleDescription);
                        sampleDescription = match.Groups[1].Value;

                        string temp = match.Groups[2].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            specie = cv.GetParam(temp, "NEWT");
                        }

                        temp = match.Groups[3].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            tissue = cv.GetParam(temp, "BTO");
                        }

                        temp = match.Groups[4].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            cellType = cv.GetParam(temp, "CL");
                        }

                        temp = match.Groups[5].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            disease = cv.GetParam(temp, "DOID");
                        }
                    }
                    if (assayRegex != null && assayRegex.IsMatch(assayReagent)) {
                        var match = assayRegex.Match(assayReagent);
                        string temp = match.Groups[2].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            foreach (var t in temp.Split(';')) {
                                mod.Add(cv.GetParam(t, "PRIDE"));
                            }
                        }

                        assayReagent = match.Groups[1].Value;
                    }

                    string filename = null;
                    string path = null;
                    Lib.Model.Param format = null;
                    Lib.Model.Param idformat = null;
                    Lib.Model.Param fragementaion = null;
                    if (runRegex != null && runRegex.IsMatch(msrunText)) {
                        var match = runRegex.Match(msrunText);
                        filename = match.Groups[1].Value;

                        string temp = match.Groups[2].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            path = temp;
                        }

                        temp = match.Groups[3].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            format = cv.GetParam(temp, "MS");
                        }

                        temp = match.Groups[4].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            idformat = cv.GetParam(temp, "MS");
                        }

                        temp = match.Groups[5].Value;
                        if (!String.IsNullOrEmpty(temp)) {
                            fragementaion = cv.GetParam(temp, "MS");
                        }
                    }

                    StudyVariable studyvariable;
                    if (!studyvariables.Any(x => x.Description.Equals(studyvariableDescription))) {
                        studyvariable = new StudyVariable(studyvariables.Count + 1) {
                            Description = studyvariableDescription
                        };
                        studyvariables.Add(studyvariable);
                    } else {
                        studyvariable = studyvariables.First(x => x.Description.Equals(studyvariableDescription));
                    }

                    Assay assay = new Assay(assays.Count + 1) {
                        QuantificationReagent = cv.GetParam(assayReagent, "PRIDE")
                    };

                    foreach (var m in mod) {
                        if (m == null) {
                            continue;
                        }
                        assay.addQuantificationMod(new AssayQuantificationMod(assay,
                                                                              assay.QuantificationModMap.Count + 1) {
                                                                                  Param = m
                                                                              });
                    }

                    assays.Add(assay);

                    MsRunImpl msrun;
                    if (!String.IsNullOrEmpty(filename) &&
                        !msruns.Any(x => x.Description != null && x.Description.Equals(filename))) {
                        msrun = new MsRunImpl(msruns.Count + 1) {
                            Format = format,
                            IdFormat = idformat,
                            FragmentationMethod = fragementaion
                        };

                        msruns.Add(msrun);
                        msrun.Location = new Url(String.IsNullOrEmpty(path) ? filename : Path.Combine(path, filename));
                    } else {
                        msrun = msruns.First(x => x.Description != null && x.Description.Equals(filename));
                    }

                    Sample sample;
                    if (!samples.Any(x => x.Description.Equals(sampleDescription))) {
                        sample = new Sample(samples.Count + 1) { Description = sampleDescription };
                        if (specie != null) {
                            sample.AddSpecies(specie);
                        }
                        if (tissue != null) {
                            sample.AddTissue(tissue);
                        }
                        if (cellType != null) {
                            sample.AddCellType(cellType);
                        }
                        if (disease != null) {
                            sample.AddDisease(disease);
                        }
                        samples.Add(sample);
                    } else {
                        sample = samples.First(x => x.Description.Equals(sampleDescription));
                    }

                    if (!studyvariable.AssayMap.ContainsKey(assay.Id)) {
                        studyvariable.AddAssay(assay);
                    }
                    if (!studyvariable.SampleMap.ContainsKey(sample.Id)) {
                        studyvariable.AddSample(sample);
                    }

                    assay.MsRun = msrun;
                    assay.Sample = sample;
                }
            }

            #endregion

            Dictionary<int, IList<string>> dictionary = new Dictionary<int, IList<string>>();

            #region parse experimentalDesign

            if (experimentalDesignTemplate != null) {
                string[] rawfiles = null;

                int index = Constants.GetKeywordIndex(experimentalDesign.rawfile,
                                                     experimentalDesignTemplate.StringColumnNames);
                if (index != -1) {
                    rawfiles = experimentalDesignTemplate.StringColumns[index];
                }

                string[] experimentNames = null;
                if (
                    (index =
                     Constants.GetKeywordIndex(experimentalDesign.variable,
                                              experimentalDesignTemplate.StringColumnNames)) !=
                    -1) {
                    experimentNames = experimentalDesignTemplate.StringColumns[index];
                } else if (
                      (index =
                       Constants.GetKeywordIndex(experimentalDesign.variable,
                                                experimentalDesignTemplate.CategoryColumnNames)) != -1) {
                    experimentNames = MzTabMatrixUtils.ConvertToStringArray(experimentalDesignTemplate.GetCategoryColumnAt(index));
                }

                if (rawfiles != null && experimentNames != null) {
                    for (int i = 0; i < rawfiles.Length && i < experimentNames.Length; i++) {
                        string name = experimentNames[i];
                        StudyVariable variable = studyvariables.FirstOrDefault(x => x.Description.Equals(name));
                        if (variable == null) {
                            variable = new StudyVariable(studyvariables.Count + 1) { Description = name };
                            studyvariables.Add(variable);
                        }

                        string rawfile = rawfiles[i];
                        MsRunImpl runImpl = msruns.FirstOrDefault(x => x.Description.Equals(rawfile));
                        if (runImpl == null) {
                            runImpl = new MsRunImpl(msruns.Count + 1) {
                                Location = new Url(rawfile),
                                Format = cv.GetParam("MS:1000563", "MS"),
                                IdFormat = cv.GetParam("MS:1000768", "MS")
                            };
                            msruns.Add(runImpl);
                        }

                        if (rawfile != null) {
                            if (!dictionary.ContainsKey(variable.Id)) {
                                dictionary.Add(variable.Id, new List<string>());
                            }
                            dictionary[variable.Id].Add(rawfile);
                        }
                    }
                } else {
                    Console.Out.WriteLine("Rawfiles " + rawfiles);
                    Console.Out.WriteLine("experimentNames " + experimentNames);
                    throw new Exception("Could not parse " + Matrix.ExperimentalDesign);
                }
            }

            #endregion

            #region add default samples from studyvariables

            if (studyvariables != null && studyvariables.Count > 0) {
                foreach (StudyVariable variable in studyvariables) {
                    string text = variable.Description;

                    Sample sample = samples.FirstOrDefault(x => text.Contains(x.Description));
                    if (sample == null) {
                        sample = new Sample(samples.Count + 1) { Description = text };
                        samples.Add(sample);
                    }
                    variable.AddSample(sample);
                }
            }

            #endregion

            #region parse summary

            if (summary != null) {
                int maxRow = msruns.Count;

                string multi = "1";
                string[] labels0 = null;
                int index;

                if ((index = Constants.GetKeywordIndex(Utils.summary.labels0, summary.StringColumnNames)) != -1) {
                    labels0 = summary.StringColumns[index];
                    multi = "1";
                } else if ((index = Constants.GetKeywordIndex(Utils.summary.labels0, summary.CategoryColumnNames)) !=
                           -1) {
                    labels0 = MzTabMatrixUtils.ConvertToStringArray(summary.GetCategoryColumnAt(index));
                    multi = "1";
                }

                string[] labels1 = null;
                if ((index = Constants.GetKeywordIndex(Utils.summary.labels1, summary.StringColumnNames)) != -1) {
                    labels1 = summary.StringColumns[index];
                    multi = "2";
                } else if ((index = Constants.GetKeywordIndex(Utils.summary.labels1, summary.CategoryColumnNames)) !=
                           -1) {
                    labels1 = MzTabMatrixUtils.ConvertToStringArray(summary.GetCategoryColumnAt(index));
                    multi = "2";
                }

                string[] labels2 = null;
                if ((index = Constants.GetKeywordIndex(Utils.summary.labels2, summary.StringColumnNames)) != -1) {
                    labels2 = summary.StringColumns[index];
                    multi = "3";
                } else if ((index = Constants.GetKeywordIndex(Utils.summary.labels2, summary.CategoryColumnNames)) !=
                           -1) {
                    labels2 = MzTabMatrixUtils.ConvertToStringArray(summary.GetCategoryColumnAt(index));
                    multi = "3";
                }

                string[] multiplicity;
                if ((index = Constants.GetKeywordIndex(Utils.summary.multiplicity, summary.StringColumnNames)) !=
                    -1) {
                    multiplicity = summary.StringColumns[index];
                    multiplicity = multiplicity.Where(x => !String.IsNullOrEmpty(x)).ToArray();
                } else if (
                      (index =
                       Constants.GetKeywordIndex(Utils.summary.multiplicity, summary.CategoryColumnNames)) !=
                      -1) {
                    multiplicity = MzTabMatrixUtils.ConvertToStringArray(summary.GetCategoryColumnAt(index));
                    multiplicity = multiplicity.Where(x => !String.IsNullOrEmpty(x)).ToArray();
                } else {
                    multiplicity = new string[maxRow];
                    for (int i = 0; i < multiplicity.Length; i++) {
                        multiplicity[i] = multi;
                    }
                }

                string[] labels;
                switch (multi) {
                    case "1":
                        labels = null;
                        break;
                    case "2":
                        labels = new[] { "L", "H" };
                        break;
                    case "3":
                        labels = new[] { "L", "H", "M" };
                        break;
                    default:
                        labels = null;
                        break;
                }

                if (labels != null) {
                    List<StudyVariable> list = new List<StudyVariable>();
                    Dictionary<int, IList<string>> dict = new Dictionary<int, IList<string>>();

                    foreach (StudyVariable studyVariable in studyvariables){
                        foreach (var variable in SILAC(studyVariable, labels)) {
                            IList<string> rawfile = null;
                            if (dictionary.ContainsKey(variable.Id)) {
                                rawfile = dictionary[variable.Id];
                            }

                            StudyVariable tmp = new StudyVariable(list.Count + 1){Description = variable.Description};
                            tmp.AddAllAssays(variable.AssayMap.Values.ToList());
                            tmp.AddAllSamples(variable.SampleMap.Values.ToList());

                            list.Add(tmp);

                            if (rawfile != null) {
                                if (!dict.ContainsKey(tmp.Id)) {
                                    dict.Add(tmp.Id, rawfile);
                                }
                            }
                        }
                    }
                    studyvariables = list;
                    dictionary = dict;
                }

                string[] rawfiles = null;
                if ((index = Constants.GetKeywordIndex(Utils.summary.rawfile, summary.StringColumnNames)) != -1) {
                    rawfiles = summary.StringColumns[index];
                    rawfiles = rawfiles.Where(x => !String.IsNullOrEmpty(x)).ToArray();
                } else if ((index = Constants.GetKeywordIndex(Utils.summary.rawfile, summary.CategoryColumnNames)) !=
                           -1) {
                    rawfiles = MzTabMatrixUtils.ConvertToStringArray(summary.GetCategoryColumnAt(index));
                    rawfiles = rawfiles.Where(x => !String.IsNullOrEmpty(x)).ToArray();
                }

                string[] orbitrapInstruments = new[] { "LTQ Orbitrap", "LTQ Orbitrap XL", "LTQ Orbitrap Velos", "LTQ Orbitrap Elite", "Q Exactive" };
                string[] instrument = null;
                if ((index = Constants.GetKeywordIndex(Utils.summary.instrument, summary.StringColumnNames)) != -1) {
                    instrument = summary.StringColumns[index];
                    instrument = instrument.Where(x => !String.IsNullOrEmpty(x)).ToArray();
                } else if ((index = Constants.GetKeywordIndex(Utils.summary.instrument, summary.CategoryColumnNames)) !=
                           -1) {
                    instrument = MzTabMatrixUtils.ConvertToStringArray(summary.GetCategoryColumnAt(index));
                    instrument = instrument.Where(x => !String.IsNullOrEmpty(x)).ToArray();
                }

                if (rawfiles != null) {
                    for (int i = 0; i < rawfiles.Length; i++) {
                        int id = assays.Count + 1;
                        string rawfile = rawfiles[i];

                        if (!dictionary.Values.Any(x => x.Contains(rawfile))) {
                            continue;
                        }

                        IList<StudyVariable> temp = new List<StudyVariable>();
                        foreach (var v in dictionary.Where(x => x.Value.Contains(rawfile))) {
                            temp.Add(studyvariables.FirstOrDefault(x => x.Id == v.Key));
                        }

                        StudyVariable variable1 = null;
                        StudyVariable variable2 = null;
                        StudyVariable variable3 = null;
                        if (temp != null) {
                            if (temp.Any()) {
                                variable1 = temp[0];
                            }
                            if (temp.Count() > 1) {
                                variable2 = temp[1];
                            }
                            if (temp.Count() > 2) {
                                variable3 = temp[2];
                            }
                        }

                        if (multiplicity[i].Equals("1")) {
                            #region Add assay for label free

                            Assay assay = new Assay(id) {
                                QuantificationReagent = cv.GetParam("Unlabeled sample", "PRIDE"),
                                MsRun = msruns[i]
                            };
                            if (variable1 != null) {
                                assay.Sample = variable1.SampleMap.Values.FirstOrDefault();
                                variable1.AddAssay(assay);
                            }
                            assays.Add(assay);

                            #endregion
                        } else if (multiplicity[i].Equals("2")) {
                            #region Add assays for Double SILAC labeling

                            Assay assay = new Assay(id) {
                                QuantificationReagent = cv.GetParam("SILAC light", "PRIDE"),
                                MsRun = msruns[i]
                            };
                            IList<AssayQuantificationMod> mods = MzTabMatrixUtils.GetQuantificationMod(labels0, i, assay);
                            if (mods != null) {
                                foreach (var m in mods) {
                                    assay.addQuantificationMod(m);
                                }
                            }
                            if (variable1 != null) {
                                assay.Sample = variable1.SampleMap.Values.FirstOrDefault();
                                variable1.AddAssay(assay);
                            }
                            assays.Add(assay);

                            assay = new Assay(id + 1) {
                                QuantificationReagent = cv.GetParam("SILAC heavy", "PRIDE"),
                                MsRun = msruns[i]
                            };
                            mods = MzTabMatrixUtils.GetQuantificationMod(labels1, i, assay);
                            if (mods != null) {
                                foreach (var m in mods) {
                                    assay.addQuantificationMod(m);
                                }
                            }
                            if (variable2 != null) {
                                assay.Sample = variable2.SampleMap.Values.FirstOrDefault();
                                variable2.AddAssay(assay);
                            }
                            assays.Add(assay);

                            #endregion
                        } else if (multiplicity[i].Equals("3")) {
                            #region Add assays for Triple SILAC labeling

                            Assay assay = new Assay(id) {
                                QuantificationReagent = cv.GetParam("SILAC light", "PRIDE"),
                                MsRun = msruns[i]
                            };
                            IList<AssayQuantificationMod> mods = MzTabMatrixUtils.GetQuantificationMod(labels0, i, assay);
                            if (mods != null) {
                                foreach (var m in mods) {
                                    assay.addQuantificationMod(m);
                                }
                            }
                            if (variable1 != null) {
                                assay.Sample = variable1.SampleMap.Values.FirstOrDefault();
                                variable1.AddAssay(assay);
                            }
                            assays.Add(assay);

                            assay = new Assay(id + 1) {
                                QuantificationReagent = cv.GetParam("SILAC medium", "PRIDE"),
                                MsRun = msruns[i]
                            };
                            mods = MzTabMatrixUtils.GetQuantificationMod(labels1, i, assay);
                            if (mods != null) {
                                foreach (var m in mods) {
                                    assay.addQuantificationMod(m);
                                }
                            }
                            if (variable2 != null) {
                                assay.Sample = variable2.SampleMap.Values.FirstOrDefault();
                                variable2.AddAssay(assay);
                            }
                            assays.Add(assay);

                            assay = new Assay(id + 2) {
                                QuantificationReagent = cv.GetParam("SILAC heavy", "PRIDE"),
                                MsRun = msruns[i]
                            };
                            mods = MzTabMatrixUtils.GetQuantificationMod(labels2, i, assay);
                            if (mods != null) {
                                foreach (var m in mods) {
                                    assay.addQuantificationMod(m);
                                }
                            }
                            if (variable3 != null) {
                                assay.Sample = variable3.SampleMap.Values.FirstOrDefault();
                                variable3.AddAssay(assay);
                            }
                            assays.Add(assay);

                            #endregion
                        }

                        if (instrument != null && !String.IsNullOrEmpty(instrument[i])) {
                            var tmp = new Instrument(instruments.Count + 1) { Name = cv.GetParam(instrument[i], "MS") };
                            if (orbitrapInstruments.Contains(instrument[i])) {
                                tmp.Source = cv.GetParam("electrospray ionization", "MS");
                                tmp.Analyzer = cv.GetParam("orbitrap", "MS");
                            }
                            instruments.Add(tmp);
                        }
                    }
                }
            }

            #endregion

            #region parse search

            Lib.Model.Param run_idFormat = cv.GetParam("MS:1000774", "MS");
            Lib.Model.Param run_format = cv.GetParam("Andromeda Peak list file", "MS");

            if (spectraRef != null && Constants.GetKeywordName(Utils.spectraRef.location, spectraRef.StringColumnNames) != null) {
                int colindex = Constants.GetKeywordIndex(Utils.spectraRef.location, spectraRef.StringColumnNames);
                string[] values =
                    ArrayUtils.UniqueValues(spectraRef.StringColumns[colindex]);

                for (int i = 0; i < values.Length; i++) {
                    Lib.Model.Param frag = null;
                    if (values[i].Contains("CID")) {
                        frag = cv.GetParam("MS:1000133", "MS");
                    } else if (values[i].Contains("HCD")) {
                        frag = cv.GetParam("MS:1000422", "MS");
                    }

                    msruns.Add(new MsRunImpl(msruns.Count + 1) {
                        IdFormat = run_idFormat,
                        Format = run_format,
                        FragmentationMethod = frag,
                        Location = new Url(values[i])
                    });
                }
            } else {
                msruns.Add(new MsRunImpl(msruns.Count + 1) {
                    IdFormat = run_idFormat,
                    Format = run_format
                });
            }

            #endregion
        }
Beispiel #15
0
        public bool AddSampleDisease(int id, Param disease)
        {
            Sample sample;
            if (!_sampleMap.ContainsKey(id)){
                sample = new Sample(id);
                sample.AddDisease(disease);
                _sampleMap.Add(id, sample);
                return true;
            }
            sample = _sampleMap[id];

            sample.AddDisease(disease);
            return true;
        }
 public override void Clear()
 {
     Value = new Sample[_count];
 }
        private void AddRow(List<string[]> matrix, List<string> columnnames, int row, MsRunImpl runImpl, Assay assay,
                            Sample sample, StudyVariable studyVariable, Instrument instrument)
        {
            string value = runImpl == null
                               ? ""
                               : string.Format(@"{0} <{1};{2};{3};{4}>", runImpl.Description, runImpl.FilePath,
                                               runImpl.Format == null ? "" : runImpl.Format.Name,
                                               runImpl.IdFormat == null ? "" : runImpl.IdFormat.Name,
                                               runImpl.FragmentationMethod == null
                                                   ? ""
                                                   : runImpl.FragmentationMethod.Name);
            matrix[columnnames.IndexOf(MetadataElement.MS_RUN.Name)][row] = value;

            value = assay == null
                        ? ""
                        : string.Format(@"{0} <{1}>", assay.QuantificationReagent.Name,
                                        StringUtils.Concat(";", ConvertToString(assay.QuantificationModMap)));
            matrix[columnnames.IndexOf(MetadataElement.ASSAY.Name)][row] = value;

            value = sample == null
                        ? ""
                        : string.Format(@"{0} <{1};{2};{3};{4}>", sample.Description,
                                        GetParamListString(sample.SpeciesList), GetParamListString(sample.TissueList),
                                        GetParamListString(sample.CellTypeList), GetParamListString(sample.DiseaseList));
            matrix[columnnames.IndexOf(MetadataElement.SAMPLE.Name)][row] = value;

            matrix[columnnames.IndexOf(MetadataElement.STUDY_VARIABLE.Name)][row] = studyVariable == null
                                                                                        ? ""
                                                                                        : studyVariable.Description;

            matrix[columnnames.IndexOf(MetadataElement.INSTRUMENT.Name)][row] = instrument == null
                                                                                    ? ""
                                                                                    : string.Format(
                                                                                        @"{0} <{1};{2};{3}>",
                                                                                        instrument.Name == null
                                                                                            ? ""
                                                                                            : instrument.Name.Name,
                                                                                        instrument.Analyzer == null
                                                                                            ? ""
                                                                                            : instrument.Analyzer.Name,
                                                                                        instrument.Detector == null
                                                                                            ? ""
                                                                                            : instrument.Detector.Name,
                                                                                        instrument.Source == null
                                                                                            ? ""
                                                                                            : instrument.Source.Name);
        }