########## 
##########
# Test biomass equation functions
##########
##########
# AUTHOR: Cole B. Brookson
# DATE OF CREATION: 2021-06-21
##########
##########

# set up =======================================================================
using DelimitedFiles, DifferentialEquations
include("./src/species_list_creation.jl")

# set position values 
organism_id_pos = 1
organism_type_pos = 2
body_size_pos = 3
lower_prey_limit_pos = 4
upper_prey_limit_pos = 5
habitat_midpoint_pos = 6
habitat_lower_limit_pos = 7
habitat_upper_limit_pos = 8
nutritional_value_pos = 9
biomass_pos = 10



x_vals = Array{Any}(undef, 50,1)
for i in 1:length(species_list)
    x_vals[i] = species_list[i][biomass_pos]
end

# function tests ===============================================================

#writedlm("./data/testing-files/network_for_biomass_tests.csv", 
#        network, ",")
#writedlm("./data/testing-files/species_list_for_biomass_tests.csv", 
#        species_list, ",")

network = readdlm("./data/testing-files/network_for_biomass_tests.csv", ',', Any)
species_list = readdlm("./data/testing-files/species_list_for_biomass_tests.csv", ',', Any)
x_vals = species_list_test[:,end]


i = 4
j = 1
growth_rate(i, species_list_test, x_vals)
habitat_overlap(i, j)
size_preference(i, j)
functional_response(species_list, i, j, 3)

get_species(species_list, 4) #should give 4
growth_rate(4, species_list, x_vals) #should give 0.0
growth_rate(48, species_list, x_vals) #should give 0.024750571910216266
habitat_overlap(4,1) # should give 1
size_preference(4,1) # should give 0.557
get_prey_items(species_list, network, 4)
get_prey_items(species_list, network, 4) # should give the below 
# [1, 3, 7, 10, 11, 12, 18, 19, 20, 24, 25, 27, 28, 30, 31, 35, 37, 38, 39, 42, 44, 45, 49]
functional_response(species_list, x, i, j, 2) # should give 0.00022567436750471628
biomass_gain(species_list, network, x_vals, response_type, i, 0.95) # should give 0.006540006435949622
get_predators(species_list, network, i) # should give [16, 23, 43, 46, 50]
biomass_loss(species_list, network, x_vals, 2, i) # should give 0.0002231092924935836
get_mortality(i, x_vals, ) # should give 0.0027366885494656884
mortality_change(i, x_vals, base_mortality, 0.95) # should give 0.002599854121992404