<commit_before>"""Abstract collection for experiment and integration of all experiment types."""

from snovault import (
    abstract_collection,
    calculated_property,
    collection,
    load_schema
)
from snovault.validators import (
    validate_item_content_post,
    validate_item_content_put,
    validate_item_content_patch,
    validate_item_content_in_place,
    no_validate_item_content_post,
    no_validate_item_content_put,
    no_validate_item_content_patch
)
from snovault.crud_views import (
    collection_add,
    item_edit,
)
from pyramid.view import view_config
from snovault.attachment import ItemWithAttachment
from snovault.util import debug_log
from .base import (
    Item,
    ALLOW_SUBMITTER_ADD,
    get_item_if_you_can,
    lab_award_attribution_embed_list
)

EXP_CATEGORIZER_SCHEMA = {
    "title": "Categorizer",
    "description": "Fields used as an additional level of categorization for an experiment",
    "type": "object",
    "properties": {
        "field": {
            "type": "string",
            "description": "The name of the field as to be displayed in tables."
        },
        "value": {
            "type": "string",
            "description": "The value displayed for the field"
        },
        "combined": {
            "type": "string",
            "description": "Combined field:value string used for categorization of this experiment."
        }
    }
}


@abstract_collection(
    name='experiments',
    unique_key='accession',
    acl=ALLOW_SUBMITTER_ADD,
    properties={
        'title': "Experiments",
        'description': 'Listing of all types of experiments.',
    })
class Experiment(Item):
    """The main experiment class."""
    item_type = 'experiment'
    base_types = ['Experiment'] + Item.base_types
    schema = load_schema('encoded:schemas/experiment.json')
    name_key = 'accession'
    rev = {
        'experiment_sets': ('ExperimentSet', 'experiments_in_set')
    }
    aggregated_items = {
        "badges": [
            "messages",
            "badge.commendation",
            "badge.warning",
            "badge.uuid",
            "badge.@id",
            "badge.badge_icon",
            "badge.description"
        ]
    }
    embedded_list = Item.embedded_list + lab_award_attribution_embed_list + [
        "badges.badge.title",
        "badges.badge.commendation",
        "badges.badge.warning",
        "badges.badge.badge_classification",
        "badges.badge.description",
        "badges.badge.badge_icon",
        "badges.messages",
        "experiment_sets.experimentset_type",
        "experiment_sets.@type",
        "experiment_sets.accession",
        # "experiment_type.display_title",
        "produced_in_pub.title",
        "produced_in_pub.abstract",
        "produced_in_pub.journal",
        "produced_in_pub.authors",
        "produced_in_pub.short_attribution",
        "produced_in_pub.date_published",
        "publications_of_exp.title",
        "publications_of_exp.abstract",
        "publications_of_exp.journal",
        "publications_of_exp.authors",
        "publications_of_exp.short_attribution",
        "publications_of_exp.date_published",
        "biosample.accession",
        "biosample.modifications_summary",
        "biosample.treatments_summary",
        "biosample.biosource_summary",
        "biosample.biosample_type",
        "biosample.biosource.biosource_type",
        "biosample.biosource.cell_line.slim_terms",
        "biosample.biosource.cell_line.synonyms",
        "biosample.biosource.tissue.slim_terms",
        "biosample.biosource.tissue.synonyms",
        "biosample.biosource.individual.organism.name",
        "biosample.modifications.modification_type",
        "biosample.modifications.display_title",
        "biosample.treatments.treatment_type",
        "biosample.treatments.display_title",
        "biosample.badges.badge.title",
        "biosample.badges.badge.commendation",
        "biosample.badges.badge.warning",
        "biosample.badges.badge.badge_classification",
        "biosample.badges.badge.description",
        "biosample.badges.badge.badge_icon",
        "biosample.badges.messages",

        "experiment_type.experiment_category",

        "files.href",
        "files.accession",
        "files.uuid",
        "files.file_size",
        "files.upload_key",
        "files.file_format",
        "files.file_classification",
        "files.file_type_detailed",
        "files.paired_end",
        "files.badges.badge.title",
        "files.badges.badge.commendation",
        "files.badges.badge.warning",
        "files.badges.badge.badge_classification",
        "files.badges.badge.description",
        "files.badges.badge.badge_icon",
        "files.badges.messages",
        "files.quality_metric.url",
        "files.quality_metric.overall_quality_status",
        "files.quality_metric_summary.*",

        "processed_files.href",
        "processed_files.accession",
        "processed_files.uuid",
        "processed_files.file_size",
        "processed_files.upload_key",
        "processed_files.file_format",
        "processed_files.file_classification",
        "processed_files.file_type_detailed",
        "processed_files.files.quality_metric.url",
        "processed_files.files.quality_metric.overall_quality_status",
        "processed_files.files.quality_metric_summary.*",

        "other_processed_files.files.href",
        "other_processed_files.title",
        "other_processed_files.description",
        "other_processed_files.type",
        "other_processed_files.files.accession",
        "other_processed_files.files.file_type_detailed",
        "other_processed_files.files.file_format",
        "other_processed_files.files.file_size",
        "other_processed_files.files.higlass_uid",
        "other_processed_files.files.genome_assembly",
        "other_processed_files.files.status",
        "other_processed_files.files.last_modified.date_modified",
        "other_processed_files.files.quality_metric.url",
        "other_processed_files.files.quality_metric.overall_quality_status",
        "other_processed_files.files.quality_metric_summary.*",
        "other_processed_files.files.notes_to_tsv",

        "reference_files.accession",
        "reference_files.file_type_detailed",
        "reference_files.file_size",<commit_msg>fix quality_metrics_embed<commit_after>"""Abstract collection for experiment and integration of all experiment types."""

from snovault import (
    abstract_collection,
    calculated_property,
    collection,
    load_schema
)
from snovault.validators import (
    validate_item_content_post,
    validate_item_content_put,
    validate_item_content_patch,
    validate_item_content_in_place,
    no_validate_item_content_post,
    no_validate_item_content_put,
    no_validate_item_content_patch
)
from snovault.crud_views import (
    collection_add,
    item_edit,
)
from pyramid.view import view_config
from snovault.attachment import ItemWithAttachment
from snovault.util import debug_log
from .base import (
    Item,
    ALLOW_SUBMITTER_ADD,
    get_item_if_you_can,
    lab_award_attribution_embed_list
)

EXP_CATEGORIZER_SCHEMA = {
    "title": "Categorizer",
    "description": "Fields used as an additional level of categorization for an experiment",
    "type": "object",
    "properties": {
        "field": {
            "type": "string",
            "description": "The name of the field as to be displayed in tables."
        },
        "value": {
            "type": "string",
            "description": "The value displayed for the field"
        },
        "combined": {
            "type": "string",
            "description": "Combined field:value string used for categorization of this experiment."
        }
    }
}


@abstract_collection(
    name='experiments',
    unique_key='accession',
    acl=ALLOW_SUBMITTER_ADD,
    properties={
        'title': "Experiments",
        'description': 'Listing of all types of experiments.',
    })
class Experiment(Item):
    """The main experiment class."""
    item_type = 'experiment'
    base_types = ['Experiment'] + Item.base_types
    schema = load_schema('encoded:schemas/experiment.json')
    name_key = 'accession'
    rev = {
        'experiment_sets': ('ExperimentSet', 'experiments_in_set')
    }
    aggregated_items = {
        "badges": [
            "messages",
            "badge.commendation",
            "badge.warning",
            "badge.uuid",
            "badge.@id",
            "badge.badge_icon",
            "badge.description"
        ]
    }
    embedded_list = Item.embedded_list + lab_award_attribution_embed_list + [
        "badges.badge.title",
        "badges.badge.commendation",
        "badges.badge.warning",
        "badges.badge.badge_classification",
        "badges.badge.description",
        "badges.badge.badge_icon",
        "badges.messages",
        "experiment_sets.experimentset_type",
        "experiment_sets.@type",
        "experiment_sets.accession",
        # "experiment_type.display_title",
        "produced_in_pub.title",
        "produced_in_pub.abstract",
        "produced_in_pub.journal",
        "produced_in_pub.authors",
        "produced_in_pub.short_attribution",
        "produced_in_pub.date_published",
        "publications_of_exp.title",
        "publications_of_exp.abstract",
        "publications_of_exp.journal",
        "publications_of_exp.authors",
        "publications_of_exp.short_attribution",
        "publications_of_exp.date_published",
        "biosample.accession",
        "biosample.modifications_summary",
        "biosample.treatments_summary",
        "biosample.biosource_summary",
        "biosample.biosample_type",
        "biosample.biosource.biosource_type",
        "biosample.biosource.cell_line.slim_terms",
        "biosample.biosource.cell_line.synonyms",
        "biosample.biosource.tissue.slim_terms",
        "biosample.biosource.tissue.synonyms",
        "biosample.biosource.individual.organism.name",
        "biosample.modifications.modification_type",
        "biosample.modifications.display_title",
        "biosample.treatments.treatment_type",
        "biosample.treatments.display_title",
        "biosample.badges.badge.title",
        "biosample.badges.badge.commendation",
        "biosample.badges.badge.warning",
        "biosample.badges.badge.badge_classification",
        "biosample.badges.badge.description",
        "biosample.badges.badge.badge_icon",
        "biosample.badges.messages",

        "experiment_type.experiment_category",

        "files.href",
        "files.accession",
        "files.uuid",
        "files.file_size",
        "files.upload_key",
        "files.file_format",
        "files.file_classification",
        "files.file_type_detailed",
        "files.paired_end",
        "files.badges.badge.title",
        "files.badges.badge.commendation",
        "files.badges.badge.warning",
        "files.badges.badge.badge_classification",
        "files.badges.badge.description",
        "files.badges.badge.badge_icon",
        "files.badges.messages",
        "files.quality_metric.url",
        "files.quality_metric.overall_quality_status",
        "files.quality_metric_summary.*",

        "processed_files.href",
        "processed_files.accession",
        "processed_files.uuid",
        "processed_files.file_size",
        "processed_files.upload_key",
        "processed_files.file_format",
        "processed_files.file_classification",
        "processed_files.file_type_detailed",
        "processed_files.quality_metric.url",
        "processed_files.quality_metric.overall_quality_status",
        "processed_files.quality_metric_summary.*",

        "other_processed_files.files.href",
        "other_processed_files.title",
        "other_processed_files.description",
        "other_processed_files.type",
        "other_processed_files.files.accession",
        "other_processed_files.files.file_type_detailed",
        "other_processed_files.files.file_format",
        "other_processed_files.files.file_size",
        "other_processed_files.files.higlass_uid",
        "other_processed_files.files.genome_assembly",
        "other_processed_files.files.status",
        "other_processed_files.files.last_modified.date_modified",
        "other_processed_files.quality_metric.url",
        "other_processed_files.quality_metric.overall_quality_status",
        "other_processed_files.quality_metric_summary.*",
        "other_processed_files.files.notes_to_tsv",

        "reference_files.accession",
        "reference_files.file_type_detailed",
        "reference_files.file_size",
{'fraction_non_alphanumeric': 0.10815071732618635, 'fraction_numerical': 0.0, 'mean_word_length': 2.8845682792406615, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5502603', 'n_tokens_mistral': 4016, 'n_tokens_neox': 3879, 'n_words': 494}