forked from automaticanalysis/automaticanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aaClass.m
executable file
·72 lines (65 loc) · 3.12 KB
/
aaClass.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
classdef aaClass
properties
Path
end
properties (SetAccess = private)
Name
Version
Date
ManuscriptRef
ManuscriptURL
aaURL
aawiki
end
methods
function obj = aaClass(varargin)
% Path
aafile = [mfilename('fullpath') '.m'];
obj.Path = fileparts(aafile);
if ~any(strcmp(varargin,'nopath'))
fprintf('\nPlease wait a moment, adding <a href = "matlab: cd %s">%s</a> to the path\n',obj.Path,obj.Name);
addpath(genpath(obj.Path)); % recursively add AA subfolders
rmpath(genpath(fullfile(obj.Path,'.git'))); % remove GitHub-related path
rmpath(genpath(fullfile(obj.Path,'external','cluster'))); % remove cluster-integration path
end
% user config directory
configdir = fullfile(getenv('HOME'),'.aa');
aas_makedir([], configdir);
addpath(configdir);
obj.Name = 'automaticanalysis';
info = loadjson(strrep(aafile,'Class.m','.json'));
obj.Version = info.Version;
obj.Date = info.Date;
% get GitHub commit info if exists
if exist(fullfile(obj.Path,'.git'),'dir')
fid = fopen(fullfile(obj.Path,'.git','logs','HEAD'),'r');
while ~(feof(fid)), line = fgetl(fid); end
fclose(fid);
% Split the line at tab (after tab = repo
% location info)
dat = textscan(line,'%s','delimiter','\t'); dat = dat{1};
% Split at spaces (second to last var = date)
dat = textscan(dat{1}, '%s','delimiter',' '); dat = dat{1};
obj.Version = [obj.Version ' (' dat{2} ')'];
obj.Date = datestr(str2double(dat{end-1})/86400 + datenum(1970,1,1),'mmm yyyy');
end
obj.ManuscriptRef = info.ManuscriptRef;
obj.ManuscriptURL = info.ManuscriptURL;
obj.aaURL = info.URL;
obj.aawiki = info.wiki;
% Greet
if ~any(strcmp(varargin,'nogreet'))
d = textscan(obj.ManuscriptRef,'%s %s %s','delimiter','.','CollectOutput',true); d = d{1};
fprintf('Welcome to aa version %s %s\n',obj.Version,obj.Date);
fprintf(' If you publish work that has used aa, please cite our manuscript:\n');
fprintf(' <a href = "%s">%s</a>\n',obj.ManuscriptURL,d{1});
fprintf(' <a href = "%s">%s</a>\n',obj.ManuscriptURL,d{2});
fprintf(' <a href = "%s">%s</a>\n',obj.ManuscriptURL,d{3});
fprintf('\nPlease visit <a href = "%s">The aa website</a> for more information!\n',obj.aaURL);
fprintf('\nHere you can find example <a href = "matlab: cd %s">parameter sets</a> and <a href = "matlab: cd %s">examples</a>.\n',...
fullfile(obj.Path,'aa_parametersets'),fullfile(obj.Path,'examples'));
fprintf('Ready.\n');
end
end
end
end