How can I find the symbol given the gene id?
Show older comments
ID and name conversion is one of the common tasks in Bioinformatics. In this problem, you will write a function symbol=geneidtosymbol(id,filename) that will return the symbol of a gene, given its GeneID. The GeneID to symbol conversion should be looked up from a file named "gene_info.txt". Each line in this file contains tab-delimited information for a gene. The first line of the file specifies what type of information is available in each column. Download and use the file available from http://sacan.biomed.drexel.edu/ftp/bmes201/final.20123/gene_info.txt (which contains the first 100 lines of the file available from: <ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene_info.gz)>.
If filename is not given, use gene_info.txt. If it is given (may be different than gene_info.txt), use the filename provided as input.
Here is what I have so far:
function out = geneidtosymbol(x)
fid=fopen('gene_info.txt','r'); %open file
if fid<0
fprintf('I am not able to open the pdb file');
out=[];
return;
end
symbol=[];
if ~feof(fid)
line=fgetl(fid);
str2num(line(3:10)) = x;
line=strsplit(line);
symbol=line{3};
end
out = symbol;
2 Comments
Geoff Hayes
on 27 Nov 2014
S - why does your code just read the first line from the file? Don't you get an error with the line str2num(line(3:18)) = x? Please describe what you are attempting with these lines of code.
S
on 29 Nov 2014
Accepted Answer
More Answers (0)
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!