def migrate_library2sample_ingoringSpreadsheet(lib):
        # check if its been migrated already
        if Sample.objects.filter(sampleid=lib.sample_name).exists():
            print "Library ", lib.library_code, "has been migrated already, skipping."
        else:
            #create an new samples.sample object
            newsampleobj = Sample(organism=lib.organism, lifestage=lib.lifestage, growthphase=lib.growthphase, phenotype=lib.phenotype, genotype=lib.genotype, source=lib.source, sourcename=Source.objects.get(pk=1), sample_concentration=0, sample_volume=0, sample_quantity=0, author_modified=User.objects.get(username="******"))

            newsampleobj.sampleid = 's' + lib.library_code
            if lib.sample_name:
                newsampleobj.sampleid = lib.sample_name
            newsampleobj.date_created = lib.date_created
            if lib.sample_notes != 'NA':
                newsampleobj.sample_notes = lib.sample_notes
            if lib.experiment_notes  != 'NA':
                newsampleobj.sample_notes = newsampleobj.sample_notes + ' ' + lib.experiment_notes
            newsampleobj.collected_on = lib.collected_on
            newsampleobj.collected_at = lib.collected_at
            newsampleobj.collected_by = lib.collected_by
            newsampleobj.treatment = lib.treatment
            newsampleobj.collaborator = lib.collaborator
            newsampleobj.sampletype = 'RNA'

            #now save it
            newsampleobj.save()

            # save back sampleid into library table
            lib.sampleid = newsampleobj
            lib.save()
Exemple #2
0
def migrate_library2sample_ingoringSpreadsheet(lib):
    # check if its been migrated already
    if Sample.objects.filter(sampleid=lib.sample_name).exists():
        print "Library ", lib.library_code, "has been migrated already, skipping."
    else:
        #create an new samples.sample object
        newsampleobj = Sample(
            organism=lib.organism,
            lifestage=lib.lifestage,
            growthphase=lib.growthphase,
            phenotype=lib.phenotype,
            genotype=lib.genotype,
            source=lib.source,
            sourcename=Source.objects.get(pk=1),
            sample_concentration=0,
            sample_volume=0,
            sample_quantity=0,
            author_modified=User.objects.get(username="******"))

        newsampleobj.sampleid = 's' + lib.library_code
        if lib.sample_name:
            newsampleobj.sampleid = lib.sample_name
        newsampleobj.date_created = lib.date_created
        if lib.sample_notes != 'NA':
            newsampleobj.sample_notes = lib.sample_notes
        if lib.experiment_notes != 'NA':
            newsampleobj.sample_notes = newsampleobj.sample_notes + ' ' + lib.experiment_notes
        newsampleobj.collected_on = lib.collected_on
        newsampleobj.collected_at = lib.collected_at
        newsampleobj.collected_by = lib.collected_by
        newsampleobj.treatment = lib.treatment
        newsampleobj.collaborator = lib.collaborator
        newsampleobj.sampletype = 'RNA'

        #now save it
        newsampleobj.save()

        # save back sampleid into library table
        lib.sampleid = newsampleobj
        lib.save()
def load_orphan_sample(rowdic):
    print rowdic

    sampleid = rowdic['sampleid']

    newsampleobj = Sample()
    if Sample.objects.filter(sampleid=sampleid).exists():
        newsampleobj = Sample.objects.get(sampleid=sampleid)


    newsampleobj.sampleid = sampleid
    # Things not in spread sheet but essential
    newsampleobj.sampletype = "RNA"
    newsampleobj.growthphase = Growthphase.objects.get(growthphase="log")
    newsampleobj.phenotype = Phenotype.objects.get(phenotype="wildtype")
    newsampleobj.author_modified = User.objects.get(username="******")
    newsampleobj.sourcename = Source.objects.get(pk=1)
    # Things From spread sheet

    #
    parentsampleid = "None"
    if sampleid[-1].isdigit():
        parentsampleid = "None"
    else:
        parentsampleid = rowdic['sampleid'][:-1]
    print parentsampleid
    newsampleobj.parent_sampleid = parentsampleid;

    #
    label_ontube = rowdic['oncap']
    if rowdic['ontube']:
        label_ontube =  rowdic['oncap'] + ' / ' + rowdic['ontube']
    newsampleobj.label_ontube = label_ontube

    #
    newsampleobj.genotype = Genotype.objects.get(genotype=rowdic['genotype'])
    newsampleobj.lifestage = Lifestage.objects.get(lifestage=rowdic['stage'])
    print rowdic['genus']
    print rowdic['species']
    print rowdic['strain']
    print rowdic['dateisolated']
    newsampleobj.organism = Organism.objects.get(genus=rowdic['genus'], species=rowdic['species'], strain=rowdic['strain'])
    if rowdic['dateisolated']:
        newsampleobj.collected_on = rowdic['dateisolated']
    newsampleobj.collected_by = rowdic['sender']
    newsampleobj.collected_by_emailid = rowdic['senderemailid']
    newsampleobj.isolation_method = rowdic['isolationmethod']
    newsampleobj.sample_dilution = rowdic['dilution']
    if rowdic['daterecieved']:
        newsampleobj.date_received  = rowdic['daterecieved']
    newsampleobj.sample_concentration = rowdic['concentration']
    newsampleobj.sample_volume = rowdic['volume']
    newsampleobj.sample_quantity = rowdic['quantity']
    newsampleobj.biological_replicate_of = rowdic['replicate']

    newsampleobj.freezer_location = rowdic['freezerlocation']
    #
    newsampleobj.sample_notes = rowdic['notesfromsender']
    print rowdic['pi']
    newsampleobj.collaborator = Collaborator.objects.get(lastname=rowdic['pi'])

    print newsampleobj
    newsampleobj.save()
            # from library object
            sampleobj.organism = libobj.organism
            sampleobj.lifestage = libobj.lifestage
            sampleobj.growthphase = libobj.growthphase
            sampleobj.phenotype = libobj.phenotype
            sampleobj.genotype = libobj.genotype
            sampleobj.collaborator = libobj.collaborator
            sampleobj.source = libobj.source
            sampleobj.sourcename = Source.objects.get(pk=1)
            sampleobj.treatment = libobj.treatment
            sampleobj.collected_at  = libobj.collected_at

            # from spread sheet
            if rowdic['dateisolated']:
                sampleobj.collected_on = rowdic['dateisolated']
            sampleobj.collected_by = rowdic['sender']
            sampleobj.collected_by_emailid = rowdic['senderemailid']
            sampleobj.isolation_method = rowdic['isolationmethod']
            if rowdic['daterecieved']:
                sampleobj.date_received = rowdic['daterecieved']
            sampleobj.sample_concentration = rowdic['concentration']
            sampleobj.sample_volume = rowdic['volume']
            sampleobj.sample_quantity = rowdic['quantity']
            sampleobj.sample_dilution = rowdic['dilution']
            sampleobj.biological_replicate_of = rowdic['replicate']
            sampleobj.freezer_location = rowdic['freezerlocation']
            sampleobj.sample_notes = libobj.sample_notes + "\n" + rowdic['notesfromsender']
            #
            parentsampleid = "None"
            if sampleid[-1].isdigit():
Exemple #5
0
def load_orphan_sample(rowdic):
    print rowdic

    sampleid = rowdic['sampleid']

    newsampleobj = Sample()
    if Sample.objects.filter(sampleid=sampleid).exists():
        newsampleobj = Sample.objects.get(sampleid=sampleid)

    newsampleobj.sampleid = sampleid
    # Things not in spread sheet but essential
    newsampleobj.sampletype = "RNA"
    newsampleobj.growthphase = Growthphase.objects.get(growthphase="log")
    newsampleobj.phenotype = Phenotype.objects.get(phenotype="wildtype")
    newsampleobj.author_modified = User.objects.get(username="******")
    newsampleobj.sourcename = Source.objects.get(pk=1)
    # Things From spread sheet

    #
    parentsampleid = "None"
    if sampleid[-1].isdigit():
        parentsampleid = "None"
    else:
        parentsampleid = rowdic['sampleid'][:-1]
    print parentsampleid
    newsampleobj.parent_sampleid = parentsampleid

    #
    label_ontube = rowdic['oncap']
    if rowdic['ontube']:
        label_ontube = rowdic['oncap'] + ' / ' + rowdic['ontube']
    newsampleobj.label_ontube = label_ontube

    #
    newsampleobj.genotype = Genotype.objects.get(genotype=rowdic['genotype'])
    newsampleobj.lifestage = Lifestage.objects.get(lifestage=rowdic['stage'])
    print rowdic['genus']
    print rowdic['species']
    print rowdic['strain']
    print rowdic['dateisolated']
    newsampleobj.organism = Organism.objects.get(genus=rowdic['genus'],
                                                 species=rowdic['species'],
                                                 strain=rowdic['strain'])
    if rowdic['dateisolated']:
        newsampleobj.collected_on = rowdic['dateisolated']
    newsampleobj.collected_by = rowdic['sender']
    newsampleobj.collected_by_emailid = rowdic['senderemailid']
    newsampleobj.isolation_method = rowdic['isolationmethod']
    newsampleobj.sample_dilution = rowdic['dilution']
    if rowdic['daterecieved']:
        newsampleobj.date_received = rowdic['daterecieved']
    newsampleobj.sample_concentration = rowdic['concentration']
    newsampleobj.sample_volume = rowdic['volume']
    newsampleobj.sample_quantity = rowdic['quantity']
    newsampleobj.biological_replicate_of = rowdic['replicate']

    newsampleobj.freezer_location = rowdic['freezerlocation']
    #
    newsampleobj.sample_notes = rowdic['notesfromsender']
    print rowdic['pi']
    newsampleobj.collaborator = Collaborator.objects.get(lastname=rowdic['pi'])

    print newsampleobj
    newsampleobj.save()
Exemple #6
0
            # from library object
            sampleobj.organism = libobj.organism
            sampleobj.lifestage = libobj.lifestage
            sampleobj.growthphase = libobj.growthphase
            sampleobj.phenotype = libobj.phenotype
            sampleobj.genotype = libobj.genotype
            sampleobj.collaborator = libobj.collaborator
            sampleobj.source = libobj.source
            sampleobj.sourcename = Source.objects.get(pk=1)
            sampleobj.treatment = libobj.treatment
            sampleobj.collected_at = libobj.collected_at

            # from spread sheet
            if rowdic['dateisolated']:
                sampleobj.collected_on = rowdic['dateisolated']
            sampleobj.collected_by = rowdic['sender']
            sampleobj.collected_by_emailid = rowdic['senderemailid']
            sampleobj.isolation_method = rowdic['isolationmethod']
            if rowdic['daterecieved']:
                sampleobj.date_received = rowdic['daterecieved']
            sampleobj.sample_concentration = rowdic['concentration']
            sampleobj.sample_volume = rowdic['volume']
            sampleobj.sample_quantity = rowdic['quantity']
            sampleobj.sample_dilution = rowdic['dilution']
            sampleobj.biological_replicate_of = rowdic['replicate']
            sampleobj.freezer_location = rowdic['freezerlocation']
            sampleobj.sample_notes = libobj.sample_notes + "\n" + rowdic[
                'notesfromsender']
            #
            parentsampleid = "None"