⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readfasta.m

📁 matlab工具箱的应用演示程序,
💻 M
字号:
function [sequence, header] = readFASTA (filename)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% function [sequence, header] = readFASTA (filename)
% 
% Reads file containing multiple proteins in FastA format. 
%
% header = cell array of sequence headers
% sequence = cell array of sequences
%          = first sequence corresponds to the first header sequence etc.
% filename = text file in FastA format
%
% Note: if header extends to more than the first line this function will
%       not work properly. Make sure the input file is in appropriate format.
% 
% Predrag Radivojac, 2001-2002
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fid = fopen(filename, 'rt');
if (fid == -1)
   error(['The file ' filename ' cannot be opened!']);
end

sequence = [];
header = [];

j = 0;
while feof(fid) == 0
    line = fgetl(fid);
    if ~isempty(line) & ischar(line)
        if line(1) == '>'
            j = j + 1;
            header{j} = line;
            sequence{j} = '';
        else
            sequence{j} = strcat(sequence{j}, line);
        end
    end
end

fclose(fid);

return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -