示例#1
0
    def test_create_small_molecule(self):
        """
        Tests that we can create a small molecule entity.
        """

        facilityId = "HMSL10001"
        sm = SmallMolecule(facility_id=facilityId)
        sm.save()

        print "New ID: %d" % sm.id
        self.assertTrue(sm.id is not None, "No ID was assigned")

        sm2 = SmallMolecule.objects.get(pk=sm.id)
        self.assertTrue(sm2 is not None, "Couldn't find the object")
        self.assertTrue(sm2.facility_id == facilityId)

        print "Created the Small Molecule: ", sm
示例#2
0
 def build_schema(self):
     schema = super(SmallMoleculeResource,self).build_schema()
     schema['fields'] = get_detail_schema(SmallMolecule(),['smallmolecule'])
     return schema 
示例#3
0
    filename = path.basename(inputFile)
    attachedFile = AttachedFile(filename=filename,
                                facility_id_for=facilityId,
                                relative_path=relativePath,
                                is_restricted=args.isRestricted)
    # lookup the Entity

    if (facilityId <= 30000):  # SM or Screen
        logger.info('look for the small molecule for:' + str(facilityId))
        saltId = util.int_converter(args.saltId)
        if (saltId is not None):
            logger.info('look for the small molecule for saltId ' +
                        str(saltId))
            try:
                sm = SmallMolecule(facility_id=facilityId, salt_id=saltId)
                attachedFile.salt_id_for = saltId
                batchId = util.int_converter(args.batchId)
                if (batchId is not None):
                    logger.info('look for the batch Id: ' + str(batchId))
                    attachedFile.batch_id_for = batchId
                    try:
                        smb = SmallMoleculeBatch(smallmolecule=sm,
                                                 facility_batch_id=batchId)
                    except ObjectDoesNotExist, e:
                        logger.error(
                            str(('No such SmallMoleculeBatch found',
                                 facilityId, saltId, batchId, e)))
                        raise e
            except ObjectDoesNotExist, e:
                logger.error(