Ejemplo n.º 1
0
def check_reference(meta, args):
    """Check and install the needed reference genome"""
    print("Checking reference")
    plan_data = json.load(open(os.path.join(args.path, "plan.json")))
    version, design, meta = ampliseq.handle_versioned_plans(plan_data, meta)
    print("Got versioned stuff")
    # If we have a genome reference, check to see if it's installed
    reference = design.get('genome_reference', None)
    print(reference)
    if not reference:
        return False
    try:
        url = reference.get('uri')
        ref_hash = reference.get('files_md5sum', {}).get('fasta')
        short_name = reference.get('short_name')
        name = reference.get('name')
        notes = reference.get('notes', "AmpliSeq Import")
        print("Got various fields")
    except KeyError as err:
        # If the key does not exist, that's fine, but it can't exist and be corrupt
        print("Corrupt genome_reference entry: {0}".format(err))
        sys.exit(1)

    # The identity_hash matching the files_md5sum.fasta hash determines whether
    # or not the genome is installed
    print("Checking reference " + ref_hash)
    if not models.ReferenceGenome.objects.filter(identity_hash=ref_hash).exists():
        reference = models.ReferenceGenome(
            enabled = False,
            identity_hash = ref_hash,
            name = name,
            notes = notes,
            short_name = short_name,
            source = url,
            status = "downloading",
            index_version = "tmap-f3"
        )
        reference.save()
        print("created new reference")
        pub = models.Publisher.objects.get(name='BED')
        upload = models.ContentUpload.objects.get(pk=args.upload_id)
        # This is a celery subtask that will run the publisher scripts on this upload again
        finish_me = run_pub_scripts.si(pub, upload)
        print("About t set check point")
        set_checkpoint(meta, args)
        print("check point set")
        # With a status starting with "Waiting" the framework will stop
        # after pre_processing, before validate.
        upload.status = "Waiting on reference"
        upload.save()
        # the subtask finish_me will be called at the end of the reference install
        # process to restart validation of the upload
        start_reference_download(url, reference, callback=finish_me)
        print("Started reference download")
        return True
    print("exiting in shame")
    return False
Ejemplo n.º 2
0
def check_reference(meta, args):
    print("Checking reference")
    plan_data = json.load(open(os.path.join(args.path, "plan.json")))
    version, design, meta = ampliseq.handle_versioned_plans(plan_data, meta)
    print("Got versioned stuff")
    reference = design.get('genome_reference', None)
    print(reference)
    if not reference:
        return False
    try:
        url = reference.get('uri')
        ref_hash = reference.get('files_md5sum', {}).get('fasta')
        short_name = reference.get('short_name')
        name = reference.get('name')
        notes = reference.get('notes', "AmpliSeq Import")
        print("Got various fields")
    except KeyError as err:
        print("Corrupt genome_reference entry: {0}".format(err))
        sys.exit(1)
    print("Checking reference " + ref_hash)
    if not models.ReferenceGenome.objects.filter(identity_hash=ref_hash).exists():
        reference = models.ReferenceGenome(
            enabled = False,
            identity_hash = ref_hash,
            name = name,
            notes = notes,
            short_name = short_name,
            source = url,
            status = "downloading",
            index_version = "tmap-f3"
        )
        reference.save()
        print("created new reference")
        pub = models.Publisher.objects.get(name='BED')
        upload = models.ContentUpload.objects.get(pk=args.upload_id)
        finish_me = run_pub_scripts.si(pub, upload)
        print("About t set check point")
        set_checkpoint(meta, args)
        print("check point set")
        upload.status = "Waiting on reference"
        upload.save()
        start_reference_download(url, reference, callback=finish_me)
        print("Started reference download")
        return True
    print("exiting in shame")
    return False
Ejemplo n.º 3
0
def check_reference(meta, args):
    print("Checking reference")
    plan_data = json.load(open(os.path.join(args.path, "plan.json")))
    version, design, meta = ampliseq.handle_versioned_plans(plan_data, meta)
    print("Got versioned stuff")
    reference = design.get('genome_reference', None)
    print(reference)
    if not reference:
        return False
    try:
        url = reference.get('uri')
        ref_hash = reference.get('files_md5sum', {}).get('fasta')
        short_name = reference.get('short_name')
        name = reference.get('name')
        notes = reference.get('notes', "AmpliSeq Import")
        print("Got various fields")
    except KeyError as err:
        print("Corrupt genome_reference entry: {0}".format(err))
        sys.exit(1)
    print("Checking reference " + ref_hash)
    if not models.ReferenceGenome.objects.filter(
            identity_hash=ref_hash).exists():
        reference = models.ReferenceGenome(enabled=False,
                                           identity_hash=ref_hash,
                                           name=name,
                                           notes=notes,
                                           short_name=short_name,
                                           source=url,
                                           status="downloading",
                                           index_version="tmap-f3")
        reference.save()
        print("created new reference")
        pub = models.Publisher.objects.get(name='BED')
        upload = models.ContentUpload.objects.get(pk=args.upload_id)
        finish_me = run_pub_scripts.si(pub, upload)
        print("About t set check point")
        set_checkpoint(meta, args)
        print("check point set")
        upload.status = "Waiting on reference"
        upload.save()
        start_reference_download(url, reference, callback=finish_me)
        print("Started reference download")
        return True
    print("exiting in shame")
    return False