Exemple #1
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);
        }
Exemple #2
0
        public override string GetValue(string fieldName)
        {
            switch (fieldName)
            {
            case Fields.Sequence:
                return(string.IsNullOrEmpty(Sequence) ? MzTab.NullFieldText : Sequence);

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

            case Fields.Accession:
                return(Accession);

            case Fields.Unique:
                return(Unique ? "1" : "0");

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

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

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

            case Fields.Reliability:
                if (Reliability == MzTab.ReliabilityScore.NotSet)
                {
                    return(MzTab.NullFieldText);
                }
                return(((int)Reliability).ToString());

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

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

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

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

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

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

            case Fields.SpectraReference:
                return(string.IsNullOrEmpty(SpectraReference) ? MzTab.NullFieldText : SpectraReference);

            case Fields.PreviousAminoAcid:
                return(default(char).Equals(PreviousAminoAcid) ? "-" :  PreviousAminoAcid.ToString());

            case Fields.FollowingAminoAcid:
                return(default(char).Equals(FollowingAminoAcid) ? "-" : FollowingAminoAcid.ToString());

            case Fields.StartResidue:
                return(StartResiduePosition.ToString());

            case Fields.EndResidue:
                return(EndResiduePosition.ToString());
            }

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

                if (condensedFieldName == Fields.SearchEngineScore)
                {
                    return(GetListValue(_searchEngineScores, indices[0]));
                }
            }

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

            throw new ArgumentException("Unexpected field name: " + fieldName);
        }