Skip to content

Commit

Permalink
Merge pull request #52 from b97pla/dataops-509_fastq_readme_rb
Browse files Browse the repository at this point in the history
Dataops 509 fastq readme
  • Loading branch information
b97pla authored Jan 24, 2024
2 parents 46830f5 + 8246380 commit a5f6dcc
Show file tree
Hide file tree
Showing 21 changed files with 509 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
pip install -r requirements/dev .
- name: Launch tests
run: |
nosetests ./tests
python -m unittest discover -s ./tests -t .
1 change: 1 addition & 0 deletions config/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ runfolder_directory: tests/resources/runfolders
general_project_directory: tests/resources/projects
staging_directory: /tmp/
project_links_directory: /tmp/
readme_directory: tests/resources/readme
dds_conf:
log_path: dds.log
port: 9999
2 changes: 1 addition & 1 deletion delivery/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.1"
__version__ = "3.1.0"
17 changes: 12 additions & 5 deletions delivery/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
FileSystemBasedUnorganisedRunfolderRepository
from delivery.repositories.staging_repository import DatabaseBasedStagingRepository
from delivery.repositories.deliveries_repository import DatabaseBasedDeliveriesRepository
from delivery.repositories.project_repository import GeneralProjectRepository, UnorganisedRunfolderProjectRepository
from delivery.repositories.project_repository import GeneralProjectRepository, \
UnorganisedRunfolderProjectRepository
from delivery.repositories.delivery_sources_repository import DatabaseBasedDeliverySourcesRepository
from delivery.repositories.sample_repository import RunfolderProjectBasedSampleRepository

Expand Down Expand Up @@ -120,13 +121,19 @@ def _assert_is_dir(directory):
project_links_directory = config["project_links_directory"]
_assert_is_dir(project_links_directory)

runfolder_repo = FileSystemBasedRunfolderRepository(runfolder_dir)
project_repository = UnorganisedRunfolderProjectRepository(
sample_repository=RunfolderProjectBasedSampleRepository()
readme_directory = config["readme_directory"]
_assert_is_dir(readme_directory)

sample_repo = RunfolderProjectBasedSampleRepository()
runfolder_repo = FileSystemBasedRunfolderRepository(
runfolder_dir
)
unorganised_runfolder_repo = FileSystemBasedUnorganisedRunfolderRepository(
runfolder_dir,
project_repository=project_repository
project_repository=UnorganisedRunfolderProjectRepository(
sample_repository=sample_repo,
readme_directory=readme_directory
)
)

general_project_dir = config['general_project_directory']
Expand Down
17 changes: 14 additions & 3 deletions delivery/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,29 @@ def __hash__(self):

class RunfolderProject(BaseProject):
"""
Model a project directory in a runfolder on disk. Note that this means that this project model only extends
to the idea of projects as subdirectories in a demultiplexed Illumina runfolder.
Model a project directory in a runfolder on disk. Note that this means that this project model
only extends to the idea of projects as subdirectories in a demultiplexed Illumina runfolder.
"""

def __init__(self, name, path, runfolder_path, runfolder_name, samples=None, project_files=None):
def __init__(
self,
name,
path,
runfolder_path,
runfolder_name,
samples=None,
project_files=None
):
"""
Instantiate a new `RunfolderProject` object
:param name: of the project
:param path: path to the project
:param runfolder_path: path the runfolder in which this project is stored.
:param runfolder_name: name of the runfolder in which this project is stored
:param samples: list of instances of Sample, representing samples in the project
:param project_files: list of instances of RunfolderFile, representing files belonging to
the project. These do not include files already accounted for in the `samples` list.
"""
self.name = name
self.path = os.path.abspath(path)
Expand Down
58 changes: 57 additions & 1 deletion delivery/models/runfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,63 @@ def __hash__(self):

class RunfolderFile(object):

def __init__(self, file_path, file_checksum=None):
def __init__(
self,
file_path,
base_path=None,
file_checksum=None
):
"""
A `RunfolderFile` object representing a file in the runfolder
If specified, the `base_path` parameter should specify the path that the file will be
considered relative to. For example, if `file_path` is `/path/to/example/file_name` and
`base_path` is `/path/to`, the file object, if moved or symlinked, will be placed under the
intermediate directory, i.e. `example/file_name`.
:param file_path: the path to the file
:param base_path: a path relative to which the file will be considered
:param file_checksum: a computed checksum for the file
"""
self.file_path = os.path.abspath(file_path)
self.file_name = os.path.basename(file_path)
self.base_path = base_path or os.path.dirname(self.file_path)
self.checksum = file_checksum

@classmethod
def create_object_from_path(
cls,
file_path,
runfolder_path,
filesystem_service,
metadata_service,
base_path=None,
checksums=None
):
"""
Factory method that creates and returns a class instance.
:param file_path: the path to the file
:param runfolder_path: the path to the runfolder containing the file
:param filesystem_service: a service which can access the file system
:param metadata_service: a MetadataService for reading and writing metadata files
:param base_path: a path relative to which the file will be considered
:param checksums: a list of pre-computed checksums that may or may not contain an entry for
the `file_path` relative to the `runfolder_path`
:return: a class object representing a file in the runfolder
"""
checksums = checksums or {}
relative_file_path = filesystem_service.relpath(
file_path,
filesystem_service.dirname(
runfolder_path
)
)
checksum = checksums[relative_file_path] \
if relative_file_path in checksums \
else metadata_service.hash_file(file_path)
return cls(
file_path,
base_path=base_path,
file_checksum=checksum
)
21 changes: 17 additions & 4 deletions delivery/models/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,31 @@ def __init__(
lane_no=None,
read_no=None,
is_index=None,
checksum=None):
base_path=None,
checksum=None
):
"""
Instantiate a new `SampleFile` object
A `SampleFile` object
If specified, the `base_path` parameter should specify the path that the file will be
considered relative to. For example, if `file_path` is `/path/to/example/file_name` and
`base_path` is `/path/to`, the file object, if moved or symlinked, will be placed under the
intermediate directory, i.e. `example/file_name`
:param sample_path: the path to the file
:param sample_name: the name of the sample
:param sample_index: the sample index designator
:param lane_no: the lane number the sequences in the file were derived from
:param read_no: the read number
:param is_index: if True, the sequence file contains index sequences
:param base_path: a path relative to which the file will be considered
:param checksum: the MD5 checksum for this SampleFile
"""
super(SampleFile, self).__init__(sample_path, file_checksum=checksum)
super(SampleFile, self).__init__(
sample_path,
base_path=base_path,
file_checksum=checksum
)
self.sample_name = sample_name
self.sample_index = sample_index
self.lane_no = lane_no
Expand All @@ -77,4 +89,5 @@ def __hash__(self):
self.lane_no,
self.read_no,
self.is_index,
self.checksum))
self.checksum
))
Loading

0 comments on commit a5f6dcc

Please sign in to comment.