Ejemplo n.º 1
0
        public void Input_Order_Is_Sorted()
        {
            string formula = "N4O4C2H4";
            var    chem    = new ChemicalFormula(formula);

            Assert.AreEqual("C2H4N4O4", chem.ToString());
        }
Ejemplo n.º 2
0
        public void Generate_Correct_Instance_From_String()
        {
            string formula     = "C6H12O6";
            var    glucoseTest = new ChemicalFormula(formula);

            // TODO: implement comparator for chemical formulas
            Assert.AreEqual(glucose.ToString(), glucoseTest.ToString());
        }
Ejemplo n.º 3
0
        public override string GetValue(string fieldName)
        {
            switch (fieldName)
            {
            case Fields.Identifier:
                return(Identifiers == null ? MzTab.NullFieldText : string.Join("|", Identifiers));

            case Fields.ChemicalFormula:
                return(ChemicalFormula.ToString());

            case Fields.Smiles:
                return(Smiles ?? MzTab.NullFieldText);

            case Fields.InChIKey:
                return(InChIKeys == null ? MzTab.NullFieldText : string.Join("|", InChIKeys));

            case Fields.Description:
                return(Description ?? MzTab.NullFieldText);

            case Fields.ExperimentMZ:
                return(ExperimentalMZ.ToString());

            case Fields.TheoreticalMZ:
                return(TheoreticalMZ.ToString());

            case Fields.Charge:
                return(Charge.ToString());

            case Fields.RetentionTime:
                return(RetentionTimes == null ? MzTab.NullFieldText : string.Join("|", RetentionTimes));

            case Fields.TaxID:
                return(TaxID.ToString());

            case Fields.Species:
                return(Species ?? MzTab.NullFieldText);

            case Fields.Database:
                return(Database ?? MzTab.NullFieldText);

            case Fields.DatabaseVersion:
                return(DatabaseVersion ?? MzTab.NullFieldText);

            case Fields.Reliability:
                return((Reliability == MzTab.MetabolomicsReliabilityScore.NotSet) ? MzTab.NullFieldText : ((int)Reliability).ToString());

            case Fields.Uri:
                return(Uri == null ? MzTab.NullFieldText : Uri.ToString());

            case Fields.SpectralReference:
                return(SpectralReference ?? MzTab.NullFieldText);

            case Fields.SearchEngine:
                return(SearchEngines == null ? MzTab.NullFieldText : string.Join("|", SearchEngines));

            case Fields.Modifications:
                return(Modifications ?? MzTab.NullFieldText);
            }

            if (fieldName.Contains("["))
            {
                string     condensedFieldName;
                List <int> indices = MzTab.GetFieldIndicies(fieldName, out condensedFieldName);

                switch (condensedFieldName)
                {
                case Fields.BestSearchEngineScores:
                    return(GetListValue(_bestSearchEngineScores, indices[0]));

                case Fields.SearchEngineScorePerMsRun:
                    return(GetListValue(_searchEngineScorePerMsRun, indices[0], indices[1]));

                case Fields.AbundanceAssay:
                    return(GetListValue(_abundanceAssays, indices[0]));

                case Fields.AbundanceStudyVariable:
                    return(GetListValue(_abundanceStudyVariables, indices[0]));

                case Fields.AbundanceStDevStudyVariable:
                    return(GetListValue(_abundanceStdevStudyVariables, indices[0]));

                case Fields.AbudnanceStdErrorStudyVariable:
                    return(GetListValue(_abundanceStandardErrorStudyVariables, indices[0]));
                }
            }

            if (fieldName.StartsWith(MzTab.OptionalColumnPrefix))
            {
                return(GetOptionalData(fieldName));
            }

            throw new ArgumentException("Unexpected field name: " + fieldName);
        }
Ejemplo n.º 4
0
 public void Generates_Correct_Formula_String()
 {
     Assert.AreEqual("C6H12O6", glucose.ToString());
     Assert.AreEqual("C16H18N2O4S", penicillin.ToString());
 }