Example #1
0
def test_premature_commit():
    with projecttest_context(set_up_project_stage='uniprot'):
        try:
            Commit()
            raise Exception('Premature commit was not supposed to be successful!')
        except DatabaseException:
            pass
Example #2
0
def test_gather_uniprot_using_network():
    with projecttest_context(set_up_project_stage='init'):
        GatherUniProt(
            uniprot_query='mnemonic:ABL1_HUMAN',
            uniprot_domain_regex='^Protein kinase(?!; truncated)(?!; inactive)',
        )
        first_uniprot_entry = models.UniProtEntry.query.first()
        first_uniprot_domain = models.UniProtDomain.query.first()
        first_target_domain = models.UniProtDomain.query.filter_by(
            is_target_domain=True).first()
        assert first_uniprot_entry.entry_name == 'ABL1_HUMAN'
        assert first_uniprot_domain.domain_id == 0
        assert first_target_domain.target_id == 'ABL1_HUMAN_D0'
        assert first_target_domain.domain_id == 2
        first_pdb_entry = models.PDBEntry.query.first()
        assert first_pdb_entry.chains.first() is not None
        all_pdb_entries = models.PDBEntry.query.all()
        assert '1OPL' in [pdb_entry.pdb_id for pdb_entry in all_pdb_entries]
        first_pdb_chain = models.PDBChain.query.first()
        assert first_pdb_chain.uniprot_domain.domain_id == 1
        first_uniprot_isoform = models.UniProtIsoform.query.first()
        assert first_uniprot_isoform.uniprot_entry.entry_name == 'ABL1_HUMAN'
        assert first_uniprot_isoform.is_canonical
        assert first_uniprot_isoform.ensembl_transcripts.first(
        ).transcript_id == 'ENST00000318560'
Example #3
0
def test_gather_pdb():
    with projecttest_context(set_up_project_stage='uniprot'):
        pdb_and_sifts_structure_files_dir = get_installed_resource_filepath(
            os.path.join('resources', 'structures'))
        GatherPDB(structure_dirs=pdb_and_sifts_structure_files_dir)
        first_pdb_chain = models.PDBChain.query.first()
        assert first_pdb_chain.observed_seq_aln_exp is not None
Example #4
0
def test_gather_pdb():
    with projecttest_context(set_up_project_stage='uniprot'):
        pdb_and_sifts_structure_files_dir = get_installed_resource_filepath(
            os.path.join('resources', 'structures')
        )
        GatherPDB(structure_dirs=pdb_and_sifts_structure_files_dir)
        first_pdb_chain = models.PDBChain.query.first()
        assert first_pdb_chain.observed_seq_aln_exp is not None
Example #5
0
def test_premature_commit():
    with projecttest_context(set_up_project_stage='uniprot'):
        try:
            Commit()
            raise Exception(
                'Premature commit was not supposed to be successful!')
        except DatabaseException:
            pass
def test_gather_ncbi_gene():
    with projecttest_context(set_up_project_stage="uniprot"):
        GatherNCBIGene(use_existing_gene2pubmed=True)
        first_ncbi_gene_row = models.NCBIGeneEntry.query.first()
        assert isinstance(first_ncbi_gene_row, models.NCBIGeneEntry)
        assert first_ncbi_gene_row.gene_id == 25
        first_publication_row = models.NCBIGenePublication.query.first()
        assert isinstance(first_publication_row, models.NCBIGenePublication)
        assert first_publication_row.pmid == 1281542
Example #7
0
def test_gather_ncbi_gene():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherNCBIGene(use_existing_gene2pubmed=True)
        first_ncbi_gene_row = models.NCBIGeneEntry.query.first()
        assert isinstance(first_ncbi_gene_row, models.NCBIGeneEntry)
        assert first_ncbi_gene_row.gene_id == 25
        first_publication_row = models.NCBIGenePublication.query.first()
        assert isinstance(first_publication_row, models.NCBIGenePublication)
        assert first_publication_row.pmid == 1281542
Example #8
0
def test_gather_cbioportal_using_network():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherCbioportalData()
        first_mutation_row = models.CbioportalMutation.query.first()
        first_mutation_in_domain_row = models.CbioportalMutation.query.filter_by(
            in_uniprot_domain=True).first()
        assert isinstance(first_mutation_row, models.CbioportalMutation)
        assert isinstance(first_mutation_in_domain_row.oncotator_aa_pos, int)
        assert first_mutation_in_domain_row.uniprot_domain.description == 'SH2'
def test_gather_cbioportal_using_network():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherCbioportalData()
        first_mutation_row = models.CbioportalMutation.query.first()
        first_mutation_in_domain_row = models.CbioportalMutation.query.filter_by(
            in_uniprot_domain=True
        ).first()
        assert isinstance(first_mutation_row, models.CbioportalMutation)
        assert isinstance(first_mutation_in_domain_row.oncotator_aa_pos, int)
        assert first_mutation_in_domain_row.uniprot_domain.description == 'SH2'
def test_gather_cbioportal():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherCbioportalData(use_existing_cbioportal_data=True, use_existing_oncotator_data=True)
        first_mutation_row = models.CbioportalMutation.query.first()
        assert first_mutation_row is not None
        first_mutation_in_domain_row = models.CbioportalMutation.query.filter_by(
            in_uniprot_domain=True
        ).first()
        assert first_mutation_in_domain_row is not None
        assert isinstance(first_mutation_in_domain_row.oncotator_aa_pos, int)
        assert first_mutation_in_domain_row.uniprot_domain.description == 'SH2'
Example #11
0
def test_gather_uniprot_no_domain_regex():
    with projecttest_context(set_up_project_stage='init'):
        GatherUniProt(uniprot_query='mnemonic:ABL1_HUMAN',
                      use_existing_data=True)
        first_uniprot_entry = models.UniProtEntry.query.first()
        first_uniprot_domain = models.UniProtDomain.query.first()
        assert first_uniprot_entry.entry_name == 'ABL1_HUMAN'
        assert first_uniprot_domain.domain_id == 0
        assert len(
            models.UniProtDomain.query.filter_by(
                is_target_domain=True).all()) == 0
Example #12
0
def test_gather_cbioportal():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherCbioportalData(use_existing_cbioportal_data=True,
                             use_existing_oncotator_data=True)
        first_mutation_row = models.CbioportalMutation.query.first()
        assert first_mutation_row is not None
        first_mutation_in_domain_row = models.CbioportalMutation.query.filter_by(
            in_uniprot_domain=True).first()
        assert first_mutation_in_domain_row is not None
        assert isinstance(first_mutation_in_domain_row.oncotator_aa_pos, int)
        assert first_mutation_in_domain_row.uniprot_domain.description == 'SH2'
Example #13
0
def test_gather_uniprot_no_domain_regex():
    with projecttest_context(set_up_project_stage='init'):
        GatherUniProt(
            uniprot_query='mnemonic:ABL1_HUMAN',
            use_existing_data=True
        )
        first_uniprot_entry = models.UniProtEntry.query.first()
        first_uniprot_domain = models.UniProtDomain.query.first()
        assert first_uniprot_entry.entry_name == 'ABL1_HUMAN'
        assert first_uniprot_domain.domain_id == 0
        assert len(models.UniProtDomain.query.filter_by(is_target_domain=True).all()) == 0
Example #14
0
def test_init_project():
    with projecttest_context(set_up_project_stage='blank'):
        InitProject(db_name='test', project_path=os.getcwd())
        assert os.path.exists(project_config_filename)
        assert os.path.exists(database_filename)
        assert os.path.exists(external_data_dirpath)
        assert os.path.exists(wsgi_filename)
        assert os.path.exists(manual_overrides_filename)
        assert app.config.get('SQLALCHEMY_DATABASE_URI') is not None
        crawldata_row = models.CrawlData.query.first()
        assert crawldata_row is not None
        assert crawldata_row.current_crawl_number == 0
        datestamps_row = models.DateStamps.query.first()
        assert datestamps_row is not None
        assert datestamps_row.crawl_number == 0
Example #15
0
def test_gather_uniprot_using_network():
    with projecttest_context(set_up_project_stage='init'):
        GatherUniProt(
            uniprot_query='mnemonic:ABL1_HUMAN',
            uniprot_domain_regex='^Protein kinase(?!; truncated)(?!; inactive)',
        )
        first_uniprot_entry = models.UniProtEntry.query.first()
        first_uniprot_domain = models.UniProtDomain.query.first()
        first_target_domain = models.UniProtDomain.query.filter_by(is_target_domain=True).first()
        assert first_uniprot_entry.entry_name == 'ABL1_HUMAN'
        assert first_uniprot_domain.domain_id == 0
        assert first_target_domain.target_id == 'ABL1_HUMAN_D0'
        assert first_target_domain.domain_id == 2
        first_pdb_entry = models.PDBEntry.query.first()
        assert first_pdb_entry.chains.first() is not None
        all_pdb_entries = models.PDBEntry.query.all()
        assert '1OPL' in [pdb_entry.pdb_id for pdb_entry in all_pdb_entries]
        first_pdb_chain = models.PDBChain.query.first()
        assert first_pdb_chain.uniprot_domain.domain_id == 1
        first_uniprot_isoform = models.UniProtIsoform.query.first()
        assert first_uniprot_isoform.uniprot_entry.entry_name == 'ABL1_HUMAN'
        assert first_uniprot_isoform.is_canonical
        assert first_uniprot_isoform.ensembl_transcripts.first().transcript_id == 'ENST00000318560'
Example #16
0
def test_gather_bindingdb():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherBindingDB(use_existing_bindingdb_data=True)
        first_bioassay_row = models.BindingDBBioassay.query.first()
        assert isinstance(first_bioassay_row, models.BindingDBBioassay)
        assert first_bioassay_row.target_name == 'ABL1'
Example #17
0
def test_projecttest_context():
    with projecttest_context() as temp_dir:
        assert os.path.exists(temp_dir)
Example #18
0
def test_gather_pdb_using_network():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherPDB()
        first_pdb_chain = models.PDBChain.query.first()
        assert first_pdb_chain.observed_seq_aln_exp is not None
Example #19
0
def test_gather_chembl_target():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherChemblTarget()
Example #20
0
def test_commit():
    with projecttest_context(set_up_project_stage='cbioportal'):
        Commit()
        crawl_data_row = models.CrawlData.query.first()
        assert crawl_data_row.safe_crawl_number == 0
Example #21
0
def test_commit():
    with projecttest_context(set_up_project_stage='cbioportal'):
        Commit()
        crawl_data_row = models.CrawlData.query.first()
        assert crawl_data_row.safe_crawl_number == 0
Example #22
0
def test_gather_pdb_using_network():
    with projecttest_context(set_up_project_stage='uniprot'):
        GatherPDB()
        first_pdb_chain = models.PDBChain.query.first()
        assert first_pdb_chain.observed_seq_aln_exp is not None