klinic / MATLAB /main.m
Tanguyvans's picture
matlab
90c8ced
raw
history blame
1.48 kB
function display_elementsForKey(connectionsMap, key)
% Check if the key exists in the connectionsMap
if isKey(connectionsMap, key)
% Get the value associated with the key
value = connectionsMap(key);
% Split the value string by the pipe symbol '|'
split_values = strsplit(value, '|');
% Display all elements associated with the key
disp(split_values);
else
disp('Key does not exist in the connectionsMap.');
end
end
data = readtable('MGREL.RRF', Delimiter='|', FileType='text', NumHeaderLines=0, VariableNamingRule='preserve');
data = renamevars(data,"#CUI1","CUI1");
data = data(1:1000,:);
% Create a Map to store connections
connectionsMap = containers.Map('KeyType','char', 'ValueType','any');
% Iterate through the connections matrix
for i = 1:size(data, 1)
% Extract node and connected node
node = data{i, 'CUI1'};
char_node = char(node);
connectedNode = data{i, 'CUI2'};
char_connectedNode = char(connectedNode);
% Check if the node is already a key in the map
if isKey(connectionsMap, char_node)
% If the node exists, append the connected node to its list
connectionsMap(char_node) = [connectionsMap(char_node),'|', char_connectedNode];
else
% If the node doesn't exist, create a new key-value pair
connectionsMap(char_node) = char_connectedNode;
end
end
display_elementsForKey(connectionsMap, 'C0000727');