www.gusucode.com > bioinfo 案例源码程序 matlab代码 > bioinfo/ConstructABioIndexedFileObjectAndAccessItsGOExample.m

    %% Construct a BioIndexedFile object and access its gene ontology (GO) terms
% This example shows how to construct a BioIndexedFile object and access
% its gene ontology (GO) terms.

% Copyright 2015 The MathWorks, Inc.


%%
% Create a variable containing full absolute path of source file.
sourcefile = which('yeastgenes.sgd');
%%
% Copy the file to the current working directory.
copyfile(sourcefile,'yeastgenes_copy.sgd');
%%
% Construct a BioIndexedFile object from the source file that is a
% tab-delimited file, considering contiguous rows with the same key as a
% single entry. Indicate that keys are located in column 3 and that header
% lines are prefaced with '!'.
gene2goObj = BioIndexedFile('mrtab','yeastgenes_copy.sgd','KeyColumn',3,'HeaderPrefix','!');

%%
% Return the GO term from all entries that are associated with the gene
% YAT2. Access entries that have a key of YAT2.
YAT2_entries = getEntryByKey(gene2goObj,'YAT2');

%%
% Adjust object interpreter to return only the column containing the GO
% term.
gene2goObj.Interpreter = @(x) regexp(x,'GO:\d+','match');

%%
% Parse the entries with a key of YAT2 and return all GO terms from those
% entries.
GO_YAT2_entries = read(gene2goObj, 'YAT2')