示例#1
0
 def test_create_project(self):
     project_loader = ProjectLoader(dbsession)
     project_loader.create_project('pytest project')
     dbsession.commit()
     last_project = dbsession.query(Project).order_by(
         Project.id.desc()).first()
     assert last_project.name == project_loader.project.name
     project_loader.delete_project(project_loader.project.geid)
     dbsession.commit()
     deleted_project = dbsession.query(Project).filter(
         Project.geid == project_loader.project.geid).first()
     assert not deleted_project
 def test_load_min(self):
     loader = ProjectDataLoader(dbsession, self.project.geid,
                                'python/tests/pytest_min.xlsx')
     assert not loader.xls.parse('Target').empty
     assert not loader.xls.parse('Guide').empty
     assert not loader.xls.parse('Amplicon').empty
     assert not loader.xls.parse('Layout').empty
     loader.load()
     dbsession.commit()
     target = dbsession.query(Target)\
                       .join(Project)\
                       .filter(Project.geid == self.project.geid)\
                       .filter(Target.name == 'test_target').one()
     assert target
     guide = dbsession.query(Guide)\
                      .join(Target)\
                      .join(Project)\
                      .filter(Project.geid == self.project.geid)\
                      .filter(Guide.name == 'test_guide')\
                      .one()
     assert guide
     amplicon = dbsession.query(Amplicon)\
                         .join(Project)\
                         .filter(Project.geid == self.project.geid)\
                         .filter(Amplicon.chromosome == 1)\
                         .filter(Amplicon.start == 1)\
                         .one()
     assert amplicon
     primer = dbsession.query(Primer)\
                       .join(Amplicon)\
                       .join(Project)\
                       .filter(Project.geid == self.project.geid)\
                       .filter(Amplicon.chromosome == 1)\
                       .filter(Amplicon.start == 1)\
                       .filter(Primer.sequence == 'AAAAA')\
                       .filter(Primer.strand == 'forward')\
                       .filter(Primer.start == 1)\
                       .filter(Primer.end == 10)\
                       .one()
     assert primer
     primer = dbsession.query(Primer)\
                       .join(Amplicon)\
                       .join(Project)\
                       .filter(Project.geid == self.project.geid)\
                       .filter(Amplicon.chromosome == 1)\
                       .filter(Amplicon.start == 1)\
                       .filter(Primer.sequence == 'CCCCC')\
                       .filter(Primer.strand == 'reverse')\
                       .filter(Primer.start == 101)\
                       .filter(Primer.end == 110)\
                       .one()
     assert primer
示例#3
0
def main():

    log = logger.get_custom_logger(os.path.join(cfg['PROJECTS_FOLDER'], 'load_ref_data.log'))

    try:
        loader = RefLoader(dbsession)
        loader.load_genomes()
        dbsession.commit()
    except Exception as e:
        log.exception(e)
        dbsession.rollback()
    finally:
        dbsession.close()
 def test_load_mouse(self):
     loader = ProjectDataLoader(dbsession, self.project.geid,
                                'python/tests/pytest_mouse.xlsx')
     assert not loader.xls.parse('Target').empty
     assert not loader.xls.parse('Guide').empty
     assert not loader.xls.parse('Amplicon').empty
     assert not loader.xls.parse('Layout').empty
     loader.load()
     dbsession.commit()
     target = dbsession.query(Target)\
                       .join(Project)\
                       .filter(Project.geid == self.project.geid)\
                       .filter(Target.name == 'test_mouse_target').one()
     assert target
     assert target.genome.name == 'Mus_musculus'
示例#5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--geid",
                        dest="geid",
                        action="store",
                        help="Project GEP ID e.g. 'GEP00001'",
                        required=True)
    options = parser.parse_args()

    log = logger.get_custom_logger(
        os.path.join(cfg['PROJECTS_FOLDER'], 'delete_project.log'))

    try:
        project = ProjectLoader(dbsession)
        project.delete_project(options.geid)
        dbsession.commit()
    except Exception as e:
        log.exception(e)
        dbsession.rollback()
    finally:
        dbsession.close()
 def teardown_method(self):
     dbsession.delete(self.project)
     dbsession.commit()
 def setup_method(self):
     project_loader = ProjectLoader(dbsession)
     project_loader.create_project('pytest')
     dbsession.commit()
     self.project = project_loader.project