Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PDB_prepare.R] Optimize helper function MINMAX_normalisation_func; #1

Open
discoleo opened this issue Jan 5, 2023 · 0 comments
Open

Comments

@discoleo
Copy link

discoleo commented Jan 5, 2023

Helper function MINMAX_normalisation_func

The range (min, max) is computed multiple times. It should be computed only once. One of the following conditions also seems redundant: (r[1] == 0) && (r[2] == 0)), as min == max.

Also, inserting a space between "#" and the comments greatly increases readability.

### Helper functions for the analysis

# MIN-MAX normalisation based on the input array
MINMAX_normalisation_func = function(array) {
	# input = numeric array;
	# returns normalised array values;
	
	# check for cases where all B-factor values are 0;
	r = range(array);
	if((r[2] - r[1] == 0) && (r[1] == 0) && (r[2] == 0)) { return (0); }
	
	return ((array - r[1]) / (r[2] - r[1]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant