lisc.Counts1D¶
- class lisc.Counts1D[source]¶
A class for collecting counts data for specified terms.
- Attributes
- counts1d array
The number of articles found for each term.
- meta_dataMetaData
Meta data information about the data collection.
Methods
__init__
()Initialize LISC Counts1D object.
add_labels
(labels[, directory, ...])Add the given list of strings as labels for the terms.
add_terms
(terms[, term_type, directory, ...])Add terms to the object.
Check how many articles were found for each term.
check_terms
([term_type])Print out the current list of terms.
Check the term with the most articles.
copy
()Return a copy of the current object.
drop_data
(n_articles)Drop terms based on number of article results.
drop_term
(label)Drop specified term(s) from the object.
get_index
(label)Get the index for a specified search term.
get_term
(label)Get a search term from the object.
make_search_term
(label)Create the combined search term for a selected term.
run_collection
([db, field, api_key, ...])Collect counts data.
unload_labels
([verbose])Unload labels from the object.
unload_terms
([term_type, reset, verbose])Completely unload terms from the object.
Attributes
Indicator for if the object has collected data.
Indicator for if the object has terms.
The labels for each term.
How many terms are included in the object.
- add_labels(labels, directory=None, check_consistency=True)¶
Add the given list of strings as labels for the terms.
- Parameters
- labelslist of str or str
Labels for each term to add to the object. If list, is assumed to be labels. If str, is assumed to be a file name to load from.
- directorySCDB or str, optional
Folder or database object specifying the file location, if loading from file.
- check_consistencybool, optional, default: True
Whether to check the object for consistency after adding labels.
- add_terms(terms, term_type=None, directory=None, append=False, check_consistency=True)¶
Add terms to the object.
- Parameters
- termslist or dict or str
Terms to add to the object. If list, assumed to be terms, which can be a list of str or a list of list of str. If dict, each key should reflect a term_type, and values the corresponding terms. If str, assumed to be a file name to load from.
- term_type{‘terms’, ‘inclusions’, ‘exclusions’}
Which type of terms to are being added.
- directorySCDB or str, optional
Folder or database object specifying the file location, if loading from file.
- appendboolean, optional, default: False
Whether to append the new term(s) to any existing terms. If False, any prior terms are cleared prior to adding current term(s).
- check_consistencybool, optional, default: True
Whether to check the object for consistency after adding terms.
Examples
Add search terms, from a list:
>>> base = Base() >>> base.add_terms(['frontal lobe', 'temporal lobe', 'parietal lobe', 'occipital lobe'])
Add inclusion terms, from a list:
>>> base.add_terms([[], ['brain'], [], []], term_type='inclusions')
Add exclusion terms, from a list:
>>> base.add_terms([['prefrontal'], [], [], []], term_type='exclusions')
- check_terms(term_type='terms')¶
Print out the current list of terms.
Examples
Check added terms:
>>> base = Base() >>> base.add_terms(['frontal lobe', 'temporal lobe', 'parietal lobe', 'occipital lobe']) >>> base.check_terms() List of terms used: frontal lobe : frontal lobe temporal lobe : temporal lobe parietal lobe : parietal lobe occipital lobe : occipital lobe
- Attributes
- term_type{‘terms’, ‘inclusions’, ‘exclusions’}
Which type of terms to use.
- copy()¶
Return a copy of the current object.
- drop_data(n_articles)[source]¶
Drop terms based on number of article results.
- Parameters
- n_articlesint
Minimum number of articles required to keep each term.
- drop_term(label)¶
Drop specified term(s) from the object.
- Parameters
- labelstr or int or list
The label of the term to drop. If str, is the label of the term. If int, is used as the index of the term. If list, drops each element of the list.
- get_index(label)¶
Get the index for a specified search term.
- Parameters
- labelstr
The label of the search term.
- Returns
- indint
The index of the requested search term.
- Raises
- IndexError
If the requested term label is not found.
- get_term(label)¶
Get a search term from the object.
- Parameters
- labelstr or int
The requested term. If str, is the label of the term. If int, is used as the index of the term.
- Returns
- termTerm
The full search term definition.
- property has_data¶
Indicator for if the object has collected data.
- property has_terms¶
Indicator for if the object has terms.
- property labels¶
The labels for each term.
- make_search_term(label)¶
Create the combined search term for a selected term.
- Parameters
- labelstr or int
The requested term. If str, is the label of the term. If int, is used as the index of the term.
- property n_terms¶
How many terms are included in the object.
- run_collection(db='pubmed', field='TIAB', api_key=None, logging=None, directory=None, verbose=False, **eutils_kwargs)[source]¶
Collect counts data.
- Parameters
- dbstr, optional, default: ‘pubmed’
Which database to access from EUtils.
- fieldstr, optional, default: ‘TIAB’
Field to search for term in. Defaults to ‘TIAB’, which is Title/Abstract.
- api_keystr, optional
An API key for a NCBI account.
- logging{None, ‘print’, ‘store’, ‘file’}, optional
What kind of logging, if any, to do for requested URLs.
- directorystr or SCDB, optional
Folder or database object specifying the save location.
- verbosebool, optional, default: False
Whether to print out updates.
- **eutils_kwargs
Additional settings for the EUtils API.
Examples
Collect counts data from added terms:
>>> counts = Counts1D() >>> counts.add_terms(['frontal lobe', 'temporal lobe', 'parietal lobe', 'occipital lobe']) >>> counts.run_collection()
- unload_labels(verbose=True)¶
Unload labels from the object.
- unload_terms(term_type='terms', reset=True, verbose=True)¶
Completely unload terms from the object.
Examples
Unload added terms:
>>> base = Base() >>> base.add_terms(['frontal lobe', 'temporal lobe', 'parietal lobe', 'occipital lobe']) >>> base.unload_terms() Unloading terms.
- Attributes
- term_type{‘terms’, ‘inclusions’, ‘exclusions’, ‘labels’, ‘all’}
Which type of terms to unload.
- resetbool, optional, default: True
Whether to reset in/exclusions to empty lists.
- verbosebool, optional
Whether to be verbose in printing out any changes.