package function.genotype.trio;

import function.external.evs.EvsCommand;
import function.external.exac.ExacCommand;
import function.external.knownvar.KnownVarCommand;
import global.Data;
import java.util.Iterator;
import static utils.CommandManager.checkValueValid;
import static utils.CommandManager.getValidDouble;
import utils.CommandOption;

/**
 *
 * @author nick
 */
public class TrioCommand {

    public static boolean isRunTier = false;

    // trio denovo
    public static boolean isTrioDenovo = false;
    public static boolean isIncludeNoflag = false;

    // trio comp het
    public static boolean isTrioCompHet = false;
    public static double combFreq = Data.NO_FILTER;

    public static void initDenovoOptions(Iterator<CommandOption> iterator) {
        CommandOption option;

        while (iterator.hasNext()) {
            option = (CommandOption) iterator.next();
            if (option.getName().equals("--include-noflag")) {
                isIncludeNoflag = true;
            } else if (option.getName().equals("--run-tier")) {
                isRunTier = true;
                EvsCommand.isIncludeEvs = true;
                ExacCommand.isIncludeExac = true;
                KnownVarCommand.isIncludeKnownVar = true;
            } else {
                continue;
            }

            iterator.remove();
        }
    }

    public static void initCompHetOptions(Iterator<CommandOption> iterator) {
        CommandOption option;

        while (iterator.hasNext()) {
            option = (CommandOption) iterator.next();
            switch (option.getName()) {
                case "--combfreq":
                case "--comb-freq":
                    checkValueValid(1, 0, option);
                    combFreq = getValidDouble(option);
                    break;
                case "--include-noflag":
                    isIncludeNoflag = true;
                    break;
                default:
                    continue;
            }

            iterator.remove();
        }
    }

    public static boolean isCombFreqValid(double value) {
        if (combFreq == Data.NO_FILTER) {
            return true;
        }

        return value <= combFreq;
    }
}

@@ -894,18 +894,22 @@
         
-if
+switch
  (option
@@ -918,24 +918,41 @@
 etName()
-.equals(
+) %7B%0A                case 
 %22--inclu
@@ -961,21 +961,20 @@
 -noflag%22
-)) %7B%0A
+:%0A  
         
@@ -973,32 +973,34 @@
                 
+  
 isIncludeNoflag 
@@ -1023,43 +1023,44 @@
     
-%7D else if (option.getName().equals(
+        break;%0A                case 
 %22--r
@@ -1067,21 +1067,22 @@
 un-tier%22
-)) %7B%0A
+:%0A    
         
@@ -1123,16 +1123,20 @@
         
+    
 EvsComma
@@ -1175,16 +1175,20 @@
         
+  
+  
 ExacComm
@@ -1205,32 +1205,36 @@
 udeExac = true;%0A
+    
                 
@@ -1291,17 +1291,52 @@
     
+    
-%7D else %7B%0A
+    break;%0A                default:%0A    
     
@@ -1897,32 +1897,32 @@
 nclude-noflag%22:%0A
-
                 
@@ -1968,32 +1968,300 @@
          break;%0A
+                case %22--run-tier%22:%0A                    isRunTier = true;%0A                    EvsCommand.isIncludeEvs = true;%0A                    ExacCommand.isIncludeExac = true;%0A                    KnownVarCommand.isIncludeKnownVar = true;%0A                    break;%0A
                 

enable tier in trio comp het