# Path: virtool/config/cls.py
# class Config:
#     db_connection_string: str
#     db_name: str
#     dev: bool
#     postgres_connection_string: str
#     redis_connection_string: str
#     b2c_client_id: str = None
#     b2c_client_secret: str = None
#     b2c_tenant: str = None
#     b2c_user_flow: str = None
#     base_url: str = ""
#     data_path: Path = None
#     fake: bool = False
#     fake_path: Path = None
#     force_version: str = None
#     host: str = None
#     no_check_files: bool = False
#     no_check_db: bool = False
#     no_fetching: bool = False
#     no_sentry: bool = False
#     port: int = 9950
#     proxy: str = None
#     use_b2c: bool = False
#     verbose: bool = False
#     sentry_dsn: str = "https://9a2f8d1a3f7a431e873207a70ef3d44d:ca6db07b82934005beceae93560a6794@sentry.io/220532"
# 
# Path: virtool/types.py



import asyncio
import logging
import os
import virtool.db.utils
import virtool.errors
import virtool.samples.utils
import virtool.utils
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict, List, Optional
from multidict import MultiDictProxy
from pymongo.results import DeleteResult
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
from virtool.config.cls import Config
from virtool.db.transforms import AbstractTransform, apply_transforms
from virtool.labels.db import AttachLabelsTransform
from virtool.samples.models import SampleArtifact, SampleReads
from virtool.samples.utils import join_legacy_read_paths
from virtool.settings.db import Settings
from virtool.subtractions.db import AttachSubtractionTransform
from virtool.types import App, Document
from virtool.uploads.models import Upload
from virtool.users.db import AttachUserTransform
from virtool.utils import base_processor, compress_file, file_stats
        all(file.get("raw", False) is False for file in files)
        and files[0]["name"] == "reads_1.fastq"
        and (sample["paired"] is False or files[1]["name"] == "reads_2.fastq")
    )


async def update_is_compressed(db, sample: Dict[str, Any]):
    """
    Update the ``is_compressed`` field for the passed ``sample`` in the database if all
    of its files are compressed.

    :param db: the application database
    :param sample: the sample document

    """
    files = sample["files"]

    names = [file["name"] for file in files]

    is_compressed = names == ["reads_1.fq.gz"] or names == [
        "reads_1.fq.gz",
        "reads_2.fq.gz",
    ]

    if is_compressed:
        await db.samples.update_one(
            {"_id": sample["_id"]}, {"$set": {"is_compressed": True}}
        )



# Path: virtool/config/cls.py
# class Config:
#     db_connection_string: str
#     db_name: str
#     dev: bool
#     postgres_connection_string: str
#     redis_connection_string: str
#     b2c_client_id: str = None
#     b2c_client_secret: str = None
#     b2c_tenant: str = None
#     b2c_user_flow: str = None
#     base_url: str = ""
#     data_path: Path = None
#     fake: bool = False
#     fake_path: Path = None
#     force_version: str = None
#     host: str = None
#     no_check_files: bool = False
#     no_check_db: bool = False
#     no_fetching: bool = False
#     no_sentry: bool = False
#     port: int = 9950
#     proxy: str = None
#     use_b2c: bool = False
#     verbose: bool = False
#     sentry_dsn: str = "https://9a2f8d1a3f7a431e873207a70ef3d44d:ca6db07b82934005beceae93560a6794@sentry.io/220532"
# 
# Path: virtool/types.py



# Path: virtool/samples/db.py
import asyncio
import logging
import os
import virtool.db.utils
import virtool.errors
import virtool.samples.utils
import virtool.utils
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict, List, Optional
from multidict import MultiDictProxy
from pymongo.results import DeleteResult
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
from virtool.config.cls import Config
from virtool.db.transforms import AbstractTransform, apply_transforms
from virtool.labels.db import AttachLabelsTransform
from virtool.samples.models import SampleArtifact, SampleReads
from virtool.samples.utils import join_legacy_read_paths
from virtool.settings.db import Settings
from virtool.subtractions.db import AttachSubtractionTransform
from virtool.types import App, Document
from virtool.uploads.models import Upload
from virtool.users.db import AttachUserTransform
from virtool.utils import base_processor, compress_file, file_stats

        all(file.get("raw", False) is False for file in files)
        and files[0]["name"] == "reads_1.fastq"
        and (sample["paired"] is False or files[1]["name"] == "reads_2.fastq")
    )


async def update_is_compressed(db, sample: Dict[str, Any]):
    """
    Update the ``is_compressed`` field for the passed ``sample`` in the database if all
    of its files are compressed.

    :param db: the application database
    :param sample: the sample document

    """
    files = sample["files"]

    names = [file["name"] for file in files]

    is_compressed = names == ["reads_1.fq.gz"] or names == [
        "reads_1.fq.gz",
        "reads_2.fq.gz",
    ]

    if is_compressed:
        await db.samples.update_one(
            {"_id": sample["_id"]}, {"$set": {"is_compressed": True}}
        )



async def compress_sample_reads(app: App, sample: Dict[str, Any]):