# Path: metatlas/datastructures/id_types.py
# OUTPUT_TYPES = [
#     OutputType("ISTDsEtc"),
#     OutputType("FinalEMA-HILIC"),
#     OutputType("FinalEMA-C18"),
#     OutputType("data_QC"),
#     OutputType("other"),
# ]
# POLARITIES = [Polarity("positive"), Polarity("negative"), Polarity("fast-polarity-switching")]
# SHORT_POLARITIES = {
#     Polarity("positive"): ShortPolarity("POS"),
#     Polarity("negative"): ShortPolarity("NEG"),
#     Polarity("fast-polarity-switching"): ShortPolarity("FPS"),
# }
# class Proposal(TypedDict):
# class LcmsRunDict(TypedDict):
# 
# Path: metatlas/datastructures/utils.py
# def get_atlas(name: AtlasName, username: Username) -> metob.Atlas:
# 
# Path: metatlas/io/write_utils.py
# def make_dir_for(file_path):
# def check_existing_file(file_path, overwrite=False):
# def export_dataframe(dataframe, file_path, description, overwrite=False, **kwargs):
# def raise_on_diff(dataframe, file_path, description, **kwargs):
# def export_dataframe_die_on_diff(dataframe, file_path, description, overwrite=False, **kwargs):
# 
# Path: metatlas/tools/util.py
# def or_default(none_or_value, default):
#     """
#     inputs:
#         none_or_value: variable to test
#         default: value to return if none_or_value is None
#     """
#     return none_or_value if none_or_value is not None else default


import getpass
import logging
import os
import pandas as pd
import traitlets
import metatlas.datastructures.metatlas_objects as metob
import metatlas.plots.dill2plots as dp
from typing import cast, Dict, List, Optional
from traitlets import Bool, TraitError, observe, validate
from traitlets import HasTraits, Int, Unicode
from traitlets.traitlets import ObserveHandler
from metatlas.datastructures.id_types import (
    AnalysisNumber,
    Experiment,
    FileMatchList,
    GroupList,
    GroupMatchList,
    LcmsRunDict,
    LcmsRunsList,
    PathString,
    Polarity,
    POLARITIES,
    Proposal,
    OutputType,
    OUTPUT_TYPES,
    ShortPolarity,
    SHORT_POLARITIES,
)
from metatlas.datastructures.utils import AtlasName, get_atlas, Username
from metatlas.io import write_utils
from metatlas.tools.util import or_default
    @property
    def short_experiment_analysis(self) -> str:
        """Short experiment analysis identifier"""
        return f"{self._exp_tokens[0]}_{self._exp_tokens[3]}_{self.output_type}_{self.analysis}"

    @property
    def short_polarity(self) -> ShortPolarity:
        """Short polarity identifier: 3 letters, upper case"""
        return SHORT_POLARITIES[self.polarity]

    @property
    def short_polarity_inverse(self) -> List[ShortPolarity]:
        """Returns the short_polarity values not used in this analysis"""
        return list(set(SHORT_POLARITIES.values()) - {self.short_polarity})

    @property
    def output_dir(self) -> PathString:
        """Creates the output directory and returns the path as a string"""
        sub_dirs = [self.experiment, self.analysis, self.output_type]
        if self.output_type not in ["data_QC"]:
            sub_dirs.append(self.short_polarity)
        out = os.path.join(self.project_directory, *sub_dirs)
        os.makedirs(out, exist_ok=True)
        return PathString(out)

    @property
    def cache_dir(self) -> PathString:
        """Creates directory for storing cache files and returns the path as a string"""
        out = os.path.join(self.project_directory, self.experiment, "cache")
        os.makedirs(out, exist_ok=True)

# Path: metatlas/datastructures/id_types.py
# OUTPUT_TYPES = [
#     OutputType("ISTDsEtc"),
#     OutputType("FinalEMA-HILIC"),
#     OutputType("FinalEMA-C18"),
#     OutputType("data_QC"),
#     OutputType("other"),
# ]
# POLARITIES = [Polarity("positive"), Polarity("negative"), Polarity("fast-polarity-switching")]
# SHORT_POLARITIES = {
#     Polarity("positive"): ShortPolarity("POS"),
#     Polarity("negative"): ShortPolarity("NEG"),
#     Polarity("fast-polarity-switching"): ShortPolarity("FPS"),
# }
# class Proposal(TypedDict):
# class LcmsRunDict(TypedDict):
# 
# Path: metatlas/datastructures/utils.py
# def get_atlas(name: AtlasName, username: Username) -> metob.Atlas:
# 
# Path: metatlas/io/write_utils.py
# def make_dir_for(file_path):
# def check_existing_file(file_path, overwrite=False):
# def export_dataframe(dataframe, file_path, description, overwrite=False, **kwargs):
# def raise_on_diff(dataframe, file_path, description, **kwargs):
# def export_dataframe_die_on_diff(dataframe, file_path, description, overwrite=False, **kwargs):
# 
# Path: metatlas/tools/util.py
# def or_default(none_or_value, default):
#     """
#     inputs:
#         none_or_value: variable to test
#         default: value to return if none_or_value is None
#     """
#     return none_or_value if none_or_value is not None else default


# Path: metatlas/datastructures/analysis_identifiers.py
import getpass
import logging
import os
import pandas as pd
import traitlets
import metatlas.datastructures.metatlas_objects as metob
import metatlas.plots.dill2plots as dp
from typing import cast, Dict, List, Optional
from traitlets import Bool, TraitError, observe, validate
from traitlets import HasTraits, Int, Unicode
from traitlets.traitlets import ObserveHandler
from metatlas.datastructures.id_types import (
    AnalysisNumber,
    Experiment,
    FileMatchList,
    GroupList,
    GroupMatchList,
    LcmsRunDict,
    LcmsRunsList,
    PathString,
    Polarity,
    POLARITIES,
    Proposal,
    OutputType,
    OUTPUT_TYPES,
    ShortPolarity,
    SHORT_POLARITIES,
)
from metatlas.datastructures.utils import AtlasName, get_atlas, Username
from metatlas.io import write_utils
from metatlas.tools.util import or_default

    @property
    def short_experiment_analysis(self) -> str:
        """Short experiment analysis identifier"""
        return f"{self._exp_tokens[0]}_{self._exp_tokens[3]}_{self.output_type}_{self.analysis}"

    @property
    def short_polarity(self) -> ShortPolarity:
        """Short polarity identifier: 3 letters, upper case"""
        return SHORT_POLARITIES[self.polarity]

    @property
    def short_polarity_inverse(self) -> List[ShortPolarity]:
        """Returns the short_polarity values not used in this analysis"""
        return list(set(SHORT_POLARITIES.values()) - {self.short_polarity})

    @property
    def output_dir(self) -> PathString:
        """Creates the output directory and returns the path as a string"""
        sub_dirs = [self.experiment, self.analysis, self.output_type]
        if self.output_type not in ["data_QC"]:
            sub_dirs.append(self.short_polarity)
        out = os.path.join(self.project_directory, *sub_dirs)
        os.makedirs(out, exist_ok=True)
        return PathString(out)

    @property
    def cache_dir(self) -> PathString:
        """Creates directory for storing cache files and returns the path as a string"""
        out = os.path.join(self.project_directory, self.experiment, "cache")
        os.makedirs(out, exist_ok=True)

        return PathString(out)