Main Content

getEntryByKey

Class: BioIndexedFile

Retrieve entries from source file associated with BioIndexedFile object using alphanumeric key

Syntax

Entries = getEntryByKey(BioIFobj, Key)

Description

Entries = getEntryByKey(BioIFobj, Key) extracts entries from the source file associated with BioIFobj, a BioIndexedFile object. It extracts and concatenates the entries specified by Key, a character vector or cell array of character vectors specifying one or more alphanumeric keys. It returns Entries, a character vector of concatenated entries. If the keys in the source file are not unique, it returns all entries that match a specified key, all at the position of the key in the Key cell array. If the keys in the source file are unique, there is a one-to-one relationship between the number and order of elements in Key and the output Entries.

Input Arguments

BioIFobj

Object of the BioIndexedFile class.

Key

Character vector or cell array of character vectors specifying one or more keys in the source file associated with BioIFobj, the BioIndexedFile object.

Output Arguments

Entries

Character vector of concatenated entries extracted from the source file associated with BioIFobj, the BioIndexedFile object.

Examples

Construct a BioIndexedFile object to access a table containing cross-references between gene names and gene ontology (GO) terms:

% Create variable containing full absolute path of source file
sourcefile = which('yeastgenes.sgd');
% Create a BioIndexedFile object from the source file. Indicate
% the source file is a tab-delimited file where contiguous rows
% with the same key are considered a single entry. Store the
% index file in the Current Folder. Indicate that keys are
% located in column 3 and that header lines are prefaced with !
gene2goObj = BioIndexedFile('mrtab', sourcefile, '.', ...
                            'KeyColumn', 3, 'HeaderPrefix','!')

Return the entries from the source file that are specified by the keys AAC1 and AAD10:

% Access entries that have the keys AAC1 and AAD10
subset_entries = getEntryByKey(gene2goObj, {'AAC1' 'AAD10'});

Tips

Use this method to visualize and explore a subset of the entries in the source file for validation purposes.