# Path: ob_pipelines/batch.py
# class BatchTask(luigi.Task):
#     """
#     Base class for an Amazon Batch job
# 
#     Amazon Batch requires you to register "jobs", which are JSON descriptions
#     for how to issue the ``docker run`` command. This Luigi Task can either
#     run a pre-registered Batch jobDefinition, OR you can register the job on 
#     the fly from a Python dict.
# 
#     :param job_definition: pre-registered job definition ARN (Amazon Resource
#         Name), of the form::
# 
#             arn:aws:batch:<region>:<user_id>:job-definition/<job-name>:<version>
# 
#     """
#     job_name = None
# 
#     def run(self):
#         bc = BatchClient()
#         job_id = bc.submit_job(self.job_definition, self.parameters,
#                                job_name=self.job_name)
#         bc.wait_on_job(job_id)
# 
# class LoggingTaskWrapper(luigi.Task):
# 
#     task_priority = luigi.Parameter(default=50)
# 
#     @property
#     def priority(self):
#         return self.task_priority
# 
#     @property
#     def task_key(self):
#         return getattr(self, "__task_key", None)
# 
#     @task_key.setter
#     def task_key(self, value):
#         setattr(self, "__task_key", value)
# 
# Path: ob_pipelines/entities/sample.py
# class Sample(object):
#     sample_id = Parameter()
# 
#     def __init__(self, *args, **kwargs):
# 
#         if 'id' in kwargs:
#             self.key = kwargs['id']
# 
#         if 'fields' in kwargs:
#             self._sample = kwargs['fields']
# 
#         if 'createdTime' in kwargs:
#             self._created_at = kwargs['createdTime']
#         else:
#             self._created_at = datetime.utcnow()
# 
# 
#     @property
#     def sample(self):
#         # TODO: remove fallback init
#         if not hasattr(self, '_sample'):
#             from ob_pipelines.entities.persistence import get_sample_by_name
#             self._sample = get_sample_by_name(self.sample_id)
#         return self._sample
# 
#     @property
#     def sample_folder(self) -> str:
#         return '{expt}/{sample}'.format(
#             bucket=settings.get_target_bucket(),
#             expt=self.experiment.name,
#             sample=self.sample_id)
# 
#     @property
#     def experiment(self):
#         # TODO: remove fallback init
#         if not hasattr(self, '_experiment'):
#             expt_key = self.sample.sample['Experiment'][0]
#             from ob_pipelines.entities.persistence import get_experiment_by_key
#             self._experiment = get_experiment_by_key(expt_key)
#         return self._experiment
# 
#     @experiment.setter
#     def experiment(self, value):
#         self._experiment = value
# 
# Path: ob_pipelines/tasks/sort_bam.py
# class SortBam(BatchTask, LoggingTaskWrapper, Sample):
#     job_definition = 'samtools-sort-by-coord'
# 
#     @property
#     def parameters(self):
#         return {
#             'input': self.input()['bam'].path,
#             'output': self.output().path,
#             'tmp_prefix': '/scratch/{}'.format(self.sample_id)
#         }
# 
#     def requires(self):
#         return Star(sample_id=self.sample_id)
# 
#     def output(self):
#         return S3Target(self.input()['bam'].path.replace('.bam', '.sorted.bam'))


from luigi.contrib.s3 import S3Target
from ob_pipelines.batch import BatchTask, LoggingTaskWrapper
from ob_pipelines.entities.sample import Sample
from ob_pipelines.tasks.sort_bam import SortBam



class IndexBam(BatchTask, LoggingTaskWrapper, Sample):
    job_definition = 'samtools-index'

    @property
    def parameters(self):
        return {

# Path: ob_pipelines/batch.py
# class BatchTask(luigi.Task):
#     """
#     Base class for an Amazon Batch job
# 
#     Amazon Batch requires you to register "jobs", which are JSON descriptions
#     for how to issue the ``docker run`` command. This Luigi Task can either
#     run a pre-registered Batch jobDefinition, OR you can register the job on 
#     the fly from a Python dict.
# 
#     :param job_definition: pre-registered job definition ARN (Amazon Resource
#         Name), of the form::
# 
#             arn:aws:batch:<region>:<user_id>:job-definition/<job-name>:<version>
# 
#     """
#     job_name = None
# 
#     def run(self):
#         bc = BatchClient()
#         job_id = bc.submit_job(self.job_definition, self.parameters,
#                                job_name=self.job_name)
#         bc.wait_on_job(job_id)
# 
# class LoggingTaskWrapper(luigi.Task):
# 
#     task_priority = luigi.Parameter(default=50)
# 
#     @property
#     def priority(self):
#         return self.task_priority
# 
#     @property
#     def task_key(self):
#         return getattr(self, "__task_key", None)
# 
#     @task_key.setter
#     def task_key(self, value):
#         setattr(self, "__task_key", value)
# 
# Path: ob_pipelines/entities/sample.py
# class Sample(object):
#     sample_id = Parameter()
# 
#     def __init__(self, *args, **kwargs):
# 
#         if 'id' in kwargs:
#             self.key = kwargs['id']
# 
#         if 'fields' in kwargs:
#             self._sample = kwargs['fields']
# 
#         if 'createdTime' in kwargs:
#             self._created_at = kwargs['createdTime']
#         else:
#             self._created_at = datetime.utcnow()
# 
# 
#     @property
#     def sample(self):
#         # TODO: remove fallback init
#         if not hasattr(self, '_sample'):
#             from ob_pipelines.entities.persistence import get_sample_by_name
#             self._sample = get_sample_by_name(self.sample_id)
#         return self._sample
# 
#     @property
#     def sample_folder(self) -> str:
#         return '{expt}/{sample}'.format(
#             bucket=settings.get_target_bucket(),
#             expt=self.experiment.name,
#             sample=self.sample_id)
# 
#     @property
#     def experiment(self):
#         # TODO: remove fallback init
#         if not hasattr(self, '_experiment'):
#             expt_key = self.sample.sample['Experiment'][0]
#             from ob_pipelines.entities.persistence import get_experiment_by_key
#             self._experiment = get_experiment_by_key(expt_key)
#         return self._experiment
# 
#     @experiment.setter
#     def experiment(self, value):
#         self._experiment = value
# 
# Path: ob_pipelines/tasks/sort_bam.py
# class SortBam(BatchTask, LoggingTaskWrapper, Sample):
#     job_definition = 'samtools-sort-by-coord'
# 
#     @property
#     def parameters(self):
#         return {
#             'input': self.input()['bam'].path,
#             'output': self.output().path,
#             'tmp_prefix': '/scratch/{}'.format(self.sample_id)
#         }
# 
#     def requires(self):
#         return Star(sample_id=self.sample_id)
# 
#     def output(self):
#         return S3Target(self.input()['bam'].path.replace('.bam', '.sorted.bam'))


# Path: ob_pipelines/tasks/index_bam.py
from luigi.contrib.s3 import S3Target
from ob_pipelines.batch import BatchTask, LoggingTaskWrapper
from ob_pipelines.entities.sample import Sample
from ob_pipelines.tasks.sort_bam import SortBam




class IndexBam(BatchTask, LoggingTaskWrapper, Sample):
    job_definition = 'samtools-index'

    @property
    def parameters(self):
        return {

            'input': self.input().path,