%   *        ANM Eigen-Solver by Matlab [eigs]       *

%   %************************************************%
%   *        ANM Eigen-Solver by Matlab [eigs]       *
%   %************************************************%
%  ======================================================
%  |  Author : Zheng Yang                               |
%  |  Email  : proteinyang@gmail.com                    |
%  |  Date   : 5/22/2006                                |
%  ======================================================

clear

%------------------------- Part 1 Read in the EIGM from 'runANM.inp' File


fidinp = fopen('runANM.inp','r');
if fidinp < 0 
  disp('Error! No runANM.inp File.')
  return  
end


A = fscanf(fidinp,'%f');
EIGM=A(3); % EIGM :  The total eigen mode you want to calculate
disp('The Eigen modes you want to calculate is : ')
disp (EIGM)

status = fclose(fidinp);

%------------------------ Part 2 Read in the PDB ID list from'PDBList.inp' 
fidPDB = fopen('PDBList.inp','r');
if fidPDB < 0 
  disp('Error! No PDBList.inp File.')
  return  
end


pdblist=fgetl(fidPDB);
pdbid = pdblist(1:4);

while pdbid ~= '===='
    eigensolver ( pdbid, EIGM );
    pdblist=fgetl(fidPDB);
    pdbid = pdblist(1:4);
end     

disp('Successfully Run! ')