"""
Classes derived from the basic classes, or constructed to extend functions.

They allow developers to use the core data structures as building blocks,
to serve customized applications.

For Further annotation models - see khipu
"""

from metDataModel.core import Experiment, Compound, EmpiricalCompound


class userData(Experiment):
    '''
    If no annotation is given, 
    the data should be list_of_features.
    list_of_empCpds is generated by annotation methods.
    '''
    meta_data = {}              # from Experiment attributes
    list_of_empCpds = []
    list_of_features = []


class annotatedCompound(EmpiricalCompound):
    '''
    Class for annotated compounds, which can have annotation from authentic standards, MS^n or other information.
    library compound will use same class

    We will have a cumulative list of annotatedCompound
    libraryCompound = annotatedCompound
    '''
    observed_mass = 0.0000


class Compound_spectra(Compound):
    '''
    Compound with added spectra from spectral databases or in silico prediciton.
    Refer to how HMDB organizes spectra for metabolites.
    '''
    meta = {}
    MS1_ESI_pos = []
    MS1_ESI_neg = []
    MS1_EISA_pos = []
    MS1_EISA_neg = []
    MS1_GC_pos = []
    MS1_GC_neg = []
    MS2_CID_pos = []
    MS2_CID_neg = []


class Contaminant:
    '''
    # mass, good_name, name, formula, ion_form, possible origin
    contaminants_pos = [
        [537.8790134, 'C2H4O2_[M6-H6+Fe3+O]+_537.879013', 'Acetic Acid', 'C2H4O2', '[M6-H6+Fe3+O]+', 'Solvent'], 
        [555.8895784, 'C2H4O2_[M6-H6+H2O+Fe3+O]+_555.889578', 'Acetic Acid', 'C2H4O2', '[M6-H6+H2O+Fe3+O]+', 'Solvent'], 
        [597.9001434, 'C2H4O2_[M7-H6+Fe3+O]+_597.900143', 'Acetic Acid', 'C2H4O2', '[M7-H6+Fe3+O]+', 'Solvent'], 
        [102.0549554, 'C4H7NO2_[M+H]+_102.054955', 'Acetonitrile.1.Acetic acid.1', 'C4H7NO2', '[M+H]+', 'Solvent'],...
    ]
    '''
    possible_origin = type_of_contaminant = ''
    mass = 0
    good_name = ''
    name = ''
    formula = ''
    ion_form = ''
    references = []

class xenobiotic_signature(EmpiricalCompound):
    '''
    A signature on a xenobiotic compound includes the parent compound and its biotransformation products.
    They can be organized on the template of EmpiricalCompound, e.g.
    { # parent compound
      "interim_id": 0,
      "neutral_formula_mass": null,
      "neutral_formula": null,
      "Database_referred": [],
      "identity": [],
      "MS1_pseudo_Spectra": [       # experimentally observed ions
        {
          "id_number": 315,
          "mz": 133.10523223876953,
          "ion_relation": "M+H+",
        },
        {
          "mz": 134.10852813720703,
          "id_number": "F97",
          "rtime": 121.099636272,
          "ion_relation": "M+H+",
        }
      ]
    }
    '''
    
    def score(self):
        '''
        Score the signature. Simplest method being count of matched ions.
        '''
        return 0
        