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

Updates to F_Measure #159

Open
wants to merge 23 commits into
base: SANA2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions f_beta_ics_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash

# Specify the single network pair to process
network1="networks/CElegans.el"
network2="networks/AThaliana.el"

# Output files
output_file="results.txt"
error_log="error_log.txt"

# Clean previous results
> "$output_file"
> "$error_log"

# SANA command base
sana_command_base="./sana2.0 -f_beta 1,z -fg1"

# Range for 'a' values (10^1 to 10^100)
declare -a a_values=()
for ((i = 1; i <= 100; i++)); do
a_values+=($(bc <<< "10^$i"))
done

# Function to parse SANA output
parse_sana_out() {
local file=$1
local ics1=0.0
local ics2=0.0
local f_beta=0.0
local ics_count=0

while IFS= read -r line; do
if [[ "$line" == "ics:"* && $ics_count -lt 2 ]]; then
if [[ $ics_count -eq 0 ]]; then
ics1=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
else
ics2=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
fi
ics_count=$((ics_count + 1))
elif [[ "$line" == *"f_beta:"* ]]; then
f_beta=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
fi
done < "$file"

echo "$ics1 $ics2 $f_beta"
}

# Process the network pair
echo "Processing: $network1 and $network2"

# Iterate over all 'a' values
for a in "${a_values[@]}"; do
echo "Running for a = $a"
suma_ics1=0
suma_ics2=0
suma_fbeta=0

for ((run = 1; run <= 10; run++)); do
echo "Run $run for a = $a"

sana_command="${sana_command_base/z/$a} $network1 -fg2 $network2"
eval "$sana_command > /dev/null"

PARA_STATUS=$?
if [[ $PARA_STATUS -ne 0 || ! -f "sana.out" ]]; then
echo "Error: Failed for $network1 and $network2, z = $a, run = $run" >> "$error_log"
continue
fi

# Parse `sana.out`
metrics=$(parse_sana_out "sana.out")
ics1=$(echo "$metrics" | awk '{print $1}')
ics2=$(echo "$metrics" | awk '{print $2}')
f_beta=$(echo "$metrics" | awk '{print $3}')

# Accumulate results
suma_ics1=$(bc -l <<< "$suma_ics1 + $ics1")
suma_ics2=$(bc -l <<< "$suma_ics2 + $ics2")
suma_fbeta=$(bc -l <<< "$suma_fbeta + $f_beta")

rm -f "sana.out"
done

# Compute averages
avg_ics1=$(bc -l <<< "$suma_ics1 / 10")
avg_ics2=$(bc -l <<< "$suma_ics2 / 10")
avg_fbeta=$(bc -l <<< "$suma_fbeta / 10")

# Save to file
{
echo "Network Pair: $network1 and $network2"
echo "a: $a"
echo "Average ics1: $avg_ics1"
echo "Average ics2: $avg_ics2"
echo "Average f_beta: $avg_fbeta"
echo ""
} >> "$output_file"
done

echo "Processing completed. Results saved to $output_file."
129 changes: 129 additions & 0 deletions f_beta_s3_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# List to store successful (Second Ec, F Measure) pairs
declare -a results_list=()
#!/bin/bash

# List of networks to process
networks=(
"networks/AThaliana.el"
"networks/CElegans.el"
"networks/DMelanogaster.el"
"networks/HSapiens.el"
"networks/human.el"

)

# Output files
output_file="results.txt"
error_log="error_log.txt"

# SANA command base
sana_command="./sana2.0 -f_beta 1,1 -fg1"

# Clean previous results
> "$output_file"
> "$error_log"

parse_sana_out() {
local file=$1
local s3=0.69
local f_beta=0.0
local s3_found=false

while IFS= read -r line; do
if [[ "$line" == "s3:"* && $s3_found == false ]]; then
s3=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
s3_found=true
elif [[ "$line" == *"f_beta:"* ]]; then
f_beta=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
fi
done < "$file"

echo "$s3 $f_beta"
}

# Function to check monotonicity
check_monotonicity() {
local pairs=$1 # Pass array by name
local increasing=true
local decreasing=true

for ((k = 0; k < ${#pairs[@]} - 2; k+=2)); do
ec1=${pairs[k]}
fb1=${pairs[k+1]}
ec2=${pairs[k+2]}
fb2=${pairs[k+3]}

# Compare to check monotonicity
if (( $(echo "$ec1 <= $ec2" | bc -l) )); then
if (( $(echo "$fb1 > $fb2" | bc -l) )); then
increasing=false
fi
else
increasing=false
fi

if (( $(echo "$ec1 >= $ec2" | bc -l) )); then
if (( $(echo "$fb1 < $fb2" | bc -l) )); then
decreasing=false
fi
else
decreasing=false
fi
done

if [[ $increasing == true || $decreasing == true ]]; then
echo "Monotonic relationship detected."
else
echo "No monotonic relationship detected."
fi
}


# Process all pairs of networks
for ((i = 0; i < ${#networks[@]}; i++)); do
for ((j = i + 1; j < ${#networks[@]}; j++)); do
network1=${networks[$i]}
network2=${networks[$j]}

echo "Processing: $network1 and $network2"
command="$sana_command $network1 -fg2 $network2 > /dev/null"
eval "$command"

PARA_STATUS=$?
if [[ $PARA_STATUS -ne 0 || ! -f "sana.out" ]]; then
echo "Error: Failed for $network1 and $network2" >> "$error_log"
continue
fi

# Parse `sana.out`
metrics=$(parse_sana_out "sana.out")
s3=$(echo "$metrics" | awk '{print $1}')
f_beta=$(echo "$metrics" | awk '{print $2}')

# Save results if valid
if [[ -n "$s3" && -n "$f_beta" ]]; then
results_list+=("$s3" "$f_beta")
{
echo "Network Pair: $network1 and $network2"
echo "s3: $s3"
echo "f_beta: $f_beta"
echo ""
} >> "$output_file"
else
echo "Invalid results for $network1 and $network2" >> "$failure_file"
fi

rm -f "sana.out"
done
done

# Check monotonicity after processing
if [[ ${#results_list[@]} -gt 2 ]]; then
echo "Analyzing monotonicity..."
check_monotonicity results_list
else
echo "Insufficient data for monotonicity analysis."
fi

# Final report
echo "Processing completed."
117 changes: 117 additions & 0 deletions f_beta_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

# List of networks to process
networks=(
"networks/AThaliana.el"
"networks/CElegans.el"
"networks/DMelanogaster.el"
"networks/HSapiens.el"
"networks/human.el"
"networks/MMusculus-3.2.101.el"
"networks/MMusculus.el"
"networks/RNorvegicus.el"
"networks/SCerevisiae-3.2.101.el"
"networks/SCerevisiae.el"
"networks/SPombe.el"
"networks/syeast0.el"
"networks/syeast05.el"
"networks/syeast10.el"
"networks/syeast15.el"
"networks/syeast20.el"
"networks/syeast25.el"
"networks/yeast.el"
)

# Output files
output_file="results.txt"
failure_file="failures.txt"
error_log="error_log.txt"

# SANA command base
sana_command="./sana2.0 -f_beta 1,0 -fg1"

# Initialize failure counter
failure_count=0

# Clean previous results
> "$output_file"
> "$failure_file"
> "$error_log"

# Function to parse `sana.out`
parse_sana_out() {
local file=$1
local second_ec=0.0
local f_beta=0.0
local ec_count=0

while IFS= read -r line; do
if [[ "$line" == *"ec:"* ]]; then
ec_value=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
ec_count=$((ec_count + 1))
if [[ $ec_count -eq 2 ]]; then
second_ec=$ec_value
fi
elif [[ "$line" == *"f_beta:"* ]]; then
f_beta=$(echo "$line" | awk -F ':' '{print $2}' | xargs)
fi
done < "$file"

echo "$second_ec $f_beta"
}

# Process all pairs of networks
for ((i = 0; i < ${#networks[@]}; i++)); do
for ((j = i + 1; j < ${#networks[@]}; j++)); do
network1=${networks[$i]}
network2=${networks[$j]}

# Build and run the SANA command
echo "Processing: $network1 and $network2"
command="$sana_command $network1 -fg2 $network2 > /dev/null"
eval "$command"

PARA_STATUS=$?
# Check if PARA_STATUS indicates an error
if [[ $PARA_STATUS -ne 0 ]]; then
echo "Error: Command failed for $network1 and $network2 with status $PARA_STATUS" >> "$error_log"
continue
fi

# Check if `sana.out` was created
if [[ ! -f "sana.out" ]]; then
echo "Error: `sana.out` not generated for $network1 and $network2" >> "$error_log"
continue
fi

# Parse `sana.out`
metrics=$(parse_sana_out "sana.out")
second_ec=$(echo "$metrics" | awk '{print $1}')
f_beta=$(echo "$metrics" | awk '{print $2}')

# Simulate a comparison to detect mismatches
if [[ "$second_ec" != "$second_ec" || "$f_beta" != "$f_beta" ]]; then
echo "Failure for $network1 and $network2" >> "$failure_file"
echo "EC: $second_ec, F-beta: $f_beta" >> "$failure_file"
echo "" >> "$failure_file"
failure_count=$((failure_count + 1))
fi

# Save results to file
{
echo "Network Pair: $network1 and $network2"
echo "ec: $second_ec"
echo "f_beta: $f_beta"
echo ""
} >> "$output_file"

# Clean up `sana.out`
rm -f "sana.out"
done
done

# Final report
echo "Processing completed."
echo "Total mismatches (failures): $failure_count"
echo "Failures logged in $failure_file"
echo "Command errors logged in $error_log"
Loading