Пример #1
0
class DataUploaderForm(Form):
    """
    When we want to upload new data into the maps system. This form is used.
    """
    name = CharField()
    vcf_files = UploadField(extensions=['.vcf', '.vcf.gz'], required=True, label="Enriched VCF",\
        help_text="Variant Call Formated sequence file enriched with resistance and location data.")

    @staticmethod
    def get_uploader_dir(pkey):
        """Returns the directory used to save uploaded data"""
        return os.path.join(settings.MEDIA_ROOT, 'm_uploads', str(pkey).zfill(8))

    def save(self, user):
        """
        Save the data into the importer
        """
        source = ImportSource.objects.create(
            name=self.cleaned_data.get('name'),
            uploader=user,
            complete=False,
        )
        source.save()

        path = self.get_uploader_dir(source.pk)
        if not os.path.isdir(path):
            os.makedirs(path)

        files = list(list(self.cleaned_data['vcf_files'].values())[0])
        for upload_file in files:
            upload_file.conclude_upload(path, user)
            ImportStrain.objects.create(import_source=source, upload_file=upload_file)

        source.save()
        return source
Пример #2
0
class UploadFastQSingleForm(UploadForm):
    my_file_type = PredictDataset.FILE_TYPE_FASTQ
    doc_title = "Create FastQ Single-Ended Prediction"
    doc = "Create a prediction from a single-ended FastQ genetic sequence file. This option involves a large file and takes more time to process that the VCF or manual options."
    fastq_file = UploadField(
        extensions=FASTQ_FILES,
        required=True,
        label="FastQ Files",
        help_text=
        "FastQ files containing the single sequence read. Multiple files can be selected, one fastq file per strain to compare."
    )
    ordered = 5
Пример #3
0
class UploadVcfForm(UploadForm):
    my_file_type = PredictDataset.FILE_TYPE_VCF
    doc_title = "Create VCF Prediction"
    doc = """Create a prediction from a variant call file in VCF format. Get more information about the <a href="http://samtools.github.io/hts-specs/VCFv4.2.pdf">VCF format here.</a>"""
    vcf_file = UploadField(
        extensions=VCF_FILES,
        required=True,
        label="VCF Files",
        help_text=
        "Variant Call Formated sequence data file. Multiple files can be selected, one vcf file per stain to compare."
    )
    ordered = 10
    btn = 'primary'
Пример #4
0
class UploadFastQSingleForm(UploadForm):
    my_file_type = PredictDataset.FILE_TYPE_FASTQ
    doc_title = "Single-Ended FastQ File"
    doc_template = "predict/types/fastq_single.html"
    doc = "Create a prediction from single-ended FastQ genetic sequence."
    fastq_file = UploadField(
        extensions=FASTQ_FILES,
        required=True,
        label="FastQ Files",
        help_text=
        "FastQ files containing the single sequence read. Multiple files can be selected, one fastq file per strain to compare."
    )
    ordered = 5
Пример #5
0
class UploadVcfForm(UploadForm):
    my_file_type = PredictDataset.FILE_TYPE_VCF
    doc_title = "Varient Call File (VCF)"
    doc_template = "predict/types/vcf.html"
    doc = "Create a prediction from a variant call file in VCF format."
    vcf_file = UploadField(
        extensions=VCF_FILES,
        required=True,
        label="VCF Files",
        help_text=
        "Variant Call Formated sequence data file. Multiple files can be selected, one vcf file per stain to compare."
    )
    ordered = 10
    btn = 'primary'
Пример #6
0
class UploadFastQPairForm(UploadForm):
    my_file_type = PredictDataset.FILE_TYPE_FASTQ2
    doc_title = "Create FastQ Pair-Ended Prediction"
    doc = "Create a prediction from a set of pair-ended FastQ genetic sequences. This option involves the largest files and takes more time to process that the VCF or manual options."
    fastq_file = UploadField(
        extensions=FASTQ_FILES,
        buckets=[('file_one', "^(.+)[\._\- ][Rr]?1\.fastq(?:\.gz)?$",
                  "Forward FastQ Files", 'file_two'),
                 ('file_two', "^(.+)[\._\- ][Rr]?2\.fastq(?:\.gz)?$",
                  "Backward FastQ Files", 'file_one')],
        required=True,
        label="FastQ Files",
        help_text=
        "FastQ file containing the forward and backward sequence. Multiple strains can be selected for comparison."
    )
    ordered = 6
Пример #7
0
class UploadFastQPairForm(UploadForm):
    my_file_type = PredictDataset.FILE_TYPE_FASTQ2
    doc_title = "Pair-Ended FastQ File"
    doc_template = "predict/types/fastq_pair.html"
    doc = "Create a prediction from a set of pair-ended FastQ genetic sequences."
    fastq_file = UploadField(
        extensions=FASTQ_FILES,
        buckets=[('file_one', "^(.+)[\._\- ][Rr]?1\.(fastq|fq)(?:\.gz)?$",
                  "Forward FastQ Files", 'file_two'),
                 ('file_two', "^(.+)[\._\- ][Rr]?2\.(fastq|fq)(?:\.gz)?$",
                  "Backward FastQ Files", 'file_one')],
        required=True,
        label="FastQ Files",
        help_text=
        "FastQ file containing the forward and backward sequence. Multiple strains can be selected for comparison."
    )
    ordered = 6