Getting Records¶
CIViCpy offeres a wide range of convenience methods as part of the civic module to retrieve different CIViC entities.
Get All Records For A Specific Entity Type¶
Features¶
- civic.get_all_features(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all features.
- Parameters:
include_status (list) – A list of statuses. Only features and their associated entities matching the given statuses will be returned. Use None to include features without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
- civic.get_all_genes(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all gene features.
- Parameters:
include_status (list) – A list of statuses. Only genes and their associated entities matching the given statuses will be returned. Use None to include genes without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Gene
objects.
- civic.get_all_factors(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all factor features.
- Parameters:
include_status (list) – A list of statuses. Only factors and their associated entities matching the given statuses will be returned. Use None to include factors without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Factor
objects.
- civic.get_all_fusions(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all fusion features.
- Parameters:
include_status (list) – A list of statuses. Only fusions and their associated entities matching the given statuses will be returned. Use None to include fusions without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Fusion
objects.
Variants¶
- civic.get_all_variants(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all variants.
- Parameters:
include_status (list) – A list of statuses. Only variants and their associated entities matching the given statuses will be returned. Use None to include variants without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Variant
objects.
- civic.get_all_gene_variants(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all gene variants.
- Parameters:
include_status (list) – A list of statuses. Only variants and their associated entities matching the given statuses will be returned. Use None to include variants without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Variant
objects of subtype gene_variant.
- civic.get_all_factor_variants(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all factor variants.
- Parameters:
include_status (list) – A list of statuses. Only variants and their associated entities matching the given statuses will be returned. Use None to include variants without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Variant
objects of subtype factor_variant.
- civic.get_all_fusion_variants(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all fusion variants.
- Parameters:
include_status (list) – A list of statuses. Only variants and their associated entities matching the given statuses will be returned. Use None to include variants without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Variant
objects of subtype fusion_variant.
Molecular Profiles¶
- civic.get_all_molecular_profiles(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all molecular profiles.
- Parameters:
include_status (list) – A list of statuses. Only molecular profiles and their associated entities matching the given statuses will be returned. Use None to include molecular profiles without any associated entities.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
MolecularProfile
objects.
Assertions¶
- civic.get_all_assertions(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all assertions.
- Parameters:
include_status (list) – A list of statuses. Only assertions matching the given statuses will be returned.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Assertion
objects.
Evidence Items¶
- civic.get_all_evidence(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all evidence items.
- Parameters:
include_status (list) – A list of statuses. Only evidence items matching the given statuses will be returned.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
EvidenceItem
objects.
Variant Groups¶
Sources¶
- civic.get_all_sources(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all sources.
- Parameters:
include_status (list) – A list of statuses. Only sources and their associated entities matching the given statuses will be returned.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Source
objects.
Diseases¶
- civic.get_all_diseases(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all diseases.
- Parameters:
include_status (list) – A list of statuses. Only diseases and their associated entities matching the given statuses will be returned.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Disease
objects.
Therapies¶
- civic.get_all_therapies(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all therapies.
- Parameters:
include_status (list) – A list of statuses. Only therapies and their associated entities matching the given statuses will be returned.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Therapy
objects.
Phenotypes¶
- civic.get_all_phenotypes(include_status=['accepted', 'submitted', 'rejected'], allow_cached=True)[source]¶
Queries CIViC for all phenotypes.
- Parameters:
include_status (list) – A list of statuses. Only phenotypes and their associated entities matching the given statuses will be returned.
allow_cached (bool) – Indicates whether or not object retrieval from CACHE is allowed. If False it will query the CIViC database directly.
- Returns:
A list of
Phenotype
objects.
By ID¶
Records can be obtained by CIViC ID through a collection of functions provided in the civic module.
Features¶
- civic.get_feature_by_id(feature_id)[source]¶
- Parameters:
gene_id (int) – A single CIViC feature ID.
- Returns:
A
Gene
, Fusion, or Factor object.
- civic.get_features_by_ids(feature_id_list)[source]¶
- Parameters:
feature_id_list (list) – A list of CIViC feature IDs to query against to cache and (as needed) CIViC.
- Returns:
A list of
Gene
, Fusion, and/or Factor objects.
- civic.get_gene_by_id(gene_id)[source]¶
- Parameters:
gene_id (int) – A single CIViC gene feature ID.
- Returns:
A
Gene
object.
- civic.get_genes_by_ids(gene_id_list)[source]¶
- Parameters:
gene_id_list (list) – A list of CIViC gene feature IDs to query against to cache and (as needed) CIViC.
- Returns:
A list of
Gene
objects.
- civic.get_factor_by_id(factor_id)[source]¶
- Parameters:
factor_id (int) – A single CIViC factor feature ID.
- Returns:
A
Factor
object.
- civic.get_factors_by_ids(factor_id_list)[source]¶
- Parameters:
factor_id_list (list) – A list of CIViC factor feature IDs to query against to cache and (as needed) CIViC.
- Returns:
A list of
Factor
objects.
Variants¶
Molecular Profiles¶
- civic.get_molecular_profile_by_id(mp_id)[source]¶
- Parameters:
mp_id (int) – A single CIViC molecular profile ID.
- Returns:
A
MolecularProfile
object.
- civic.get_molecular_profiles_by_ids(mp_id_list)[source]¶
- Parameters:
mp_id_list (list) – A list of CIViC molecular profile IDs to query against to cache and (as needed) CIViC.
- Returns:
A list of
MolecularProfile
objects.
Assertions¶
Evidence Items¶
Variant Groups¶
Sources¶
Diseases¶
Therapies¶
Phenotypes¶
By Coordinates¶
Variant records can be searched by GRCh37 coordinates. To query specific genomic coordinates, you will
need to construct a CoordinateQuery
object, and pass this query to the
search_variants_by_coordinates()
function. If you wish to query multiple genomic coordinates (e.g.
a set of variants observed in a patient tumor), construct a sorted list of CoordinateQuery
objects
(sorted by chr, start, stop, alt), and pass the list to the bulk_search_variants_by_coordinates()
function.
- class civic.CoordinateQuery(chr, start, stop, alt=None, ref=None, build='GRCh37', key=None)[source]¶
A namedtuple with preset fields describing a genomic coordinate, for use with coordinate-based queries of CIViC Variants.
- Parameters:
chr (str) – A chromosome of value 1-23, X, Y
start (int) – The chromosomal start position in base coordinates (1-based)
stop (int) – The chromosomal stop position in base coordinates (1-based)
alt (str optional) – The alternate nucleotide(s) at the designated coordinates
ref (str optional) – The reference nucleotide(s) at the designated coordinates
build (NCBI36,GRCh37,GRCh38) – The reference build version of the coordinates
key (Any optional) – A user-defined object linked to the coordinate
- civic.search_variants_by_coordinates(coordinate_query, search_mode='any')[source]¶
Search the cache for variants matching provided coordinates using the corresponding search mode.
- Parameters:
coordinate_query (CoordinateQuery) – Coordinates to query
search_mode (any,query_encompassing,variant_encompassing,exact) –
any : any overlap between a query and a variant is a match
query_encompassing : CIViC variant records must fit within the coordinates of the query
record_encompassing : CIViC variant records must encompass the coordinates of the query
exact : variants must match coordinates precisely, as well as reference allele(s) and alternate allele(s). Use
'*'
in the coordinate_query as a wildcard for reference and/or alternate alleles. UsingNone
in the coordinate_query for reference or alternate alleles will only match variants that have no reference or alternate alleles, respectively (e.g. indels)search_mode is any by default
- Returns:
Returns a list of variant hashes matching the coordinates and search_mode
- civic.bulk_search_variants_by_coordinates(sorted_queries, search_mode='any')[source]¶
An interator to search the cache for variants matching the set of sorted coordinates and yield matches corresponding to the search mode.
- Parameters:
sorted_queries (list[CoordinateQuery]) – Sorted list of coordinates to query
search_mode (any,query_encompassing,variant_encompassing,exact) –
any : any overlap between a query and a variant is a match
query_encompassing : CIViC variant records must fit within the coordinates of the query
record_encompassing : CIViC variant records must encompass the coordinates of the query
exact : variants must match coordinates precisely, as well as reference allele(s) and alternate allele(s). Use
'*'
in the coordinate_query as a wildcard for reference and/or alternate alleles. UsingNone
in the coordinate_query for reference or alternate alleles will only match variants that have no reference or alternate alleles, respectively (e.g. indels)search_mode is any by default
- Returns:
returns a dictionary of Match lists, keyed by query
Coordinates can also be used to query Assertion
and
Evidence
records:
- civic.search_assertions_by_coordinates(coordinates, search_mode='any')[source]¶
Search the cache for variants matching provided coordinates using the corresponding search mode and return all assertions linked to any molecular profile involving those variants.
- Parameters:
coordinate_query (CoordinateQuery) – Coordinates to query
search_mode (any,query_encompassing,variant_encompassing,exact) –
any : any overlap between a query and a variant is a match
query_encompassing : CIViC variant records must fit within the coordinates of the query
record_encompassing : CIViC variant records must encompass the coordinates of the query
exact : variants must match coordinates precisely, as well as reference allele(s) and alternate allele(s). Use
'*'
in the coordinate_query as a wildcard for reference and/or alternate alleles. UsingNone
in the coordinate_query for reference or alternate alleles will only match variants that have no reference or alternate alleles, respectively (e.g. indels)search_mode is any by default
- Returns:
A list of
Assertion
objects linked to molecular profiles involving variants matching the coordinates and search_mode
- civic.search_evidence_by_coordinates(coordinates, search_mode='any')[source]¶
Search the cache for variants matching provided coordinates using the corresponding search mode and return all evidence items linked to any molecular profile involving those variants.
- Parameters:
coordinate_query (CoordinateQuery) – Coordinates to query
search_mode (any,query_encompassing,variant_encompassing,exact) –
any : any overlap between a query and a variant is a match
query_encompassing : CIViC variant records must fit within the coordinates of the query
record_encompassing : CIViC variant records must encompass the coordinates of the query
exact : variants must match coordinates precisely, as well as reference allele(s) and alternate allele(s). Use
'*'
in the coordinate_query as a wildcard for reference and/or alternate alleles. UsingNone
in the coordinate_query for reference or alternate alleles will only match variants that have no reference or alternate alleles, respectively (e.g. indels)search_mode is any by default
- Returns:
A list of
EvidenceItem
objects linked to molecular profiles involving variants matching the coordinates and search_mode
By Other Attribute¶
Genes¶
- civic.get_gene_by_name(name)[source]¶
- Parameters:
name (str) – A HGNC Gene Symbol.
- Returns:
A
Gene
object.
Factors¶
- civic.get_factor_by_ncit_id(ncit_id)[source]¶
- Parameters:
ncit_id (str) – A factor NCIthesaurus ID.
- Returns:
A
Factor
object.
Fusions¶
Variants¶
- civic.search_variants_by_allele_registry_id(caid)[source]¶
Search the cache for variants matching the queried Allele Registry ID (CAID)
- Parameters:
caid (str) – Allele Registry ID to query
- Returns:
Returns a list of variant hashes matching the Allele Registry ID
Sources¶
- civic.get_pubmed_source_by_id(pmid)[source]¶
- Parameters:
pmid (str) – A PubMed ID.
- Returns:
A
Source
object.
Diseases¶
- civic.get_disease_by_doid(doid)[source]¶
- Parameters:
doid (str) – A single Disease Ontology ID.
- Returns:
A
Disease
object.
- civic.get_disease_by_name(name)[source]¶
- Parameters:
name (str) – A single Disease Ontology name.
- Returns:
A
Disease
object.
Therapies¶
- civic.get_therapy_by_ncit_id(ncit_id)[source]¶
- Parameters:
ncit_id (str) – A single NCIthesaurus ID.
- Returns:
A
Therapy
object.
- civic.get_therapy_by_name(name)[source]¶
- Parameters:
name (str) – A single NCIthesaurus name.
- Returns:
A
Therapy
object.
Phenotypes¶
- civic.get_phenotype_by_hpo_id(hpo_id)[source]¶
- Parameters:
hpo_id (str) – A single Human Phenotype Ontology ID.
- Returns:
A
Phenotype
object.
- civic.get_phenotype_by_name(name)[source]¶
- Parameters:
name (str) – A single Human Phenotype Ontology name (sometimes also referred to as HPO class).
- Returns:
A
Phenotype
object.