All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.bio.seq.alignment.muscle.MuscleSettings Maven / Gradle / Ivy

There is a newer version: 20241122
Show newest version
package com.hfg.bio.seq.alignment.muscle;


import java.io.File;

import com.hfg.setting.*;
import com.hfg.util.StringUtil;
import com.hfg.xml.XMLTag;

//==============================================================================
/**
 Settings used for Muscle multiple sequence alignment execution.

 @author J. Alex Taylor, hairyfatguy.com
 */
//==============================================================================
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//==============================================================================
// http://www.drive5.com/muscle

public class MuscleSettings extends Settings implements Cloneable
{
   public static final String EXECUTABLE_DIR      = "executable_dir";
   public static final String EXECUTABLE          = "executable";
   public static final String INPUT_FILENAME      = "input_filename";
   public static final String OUTPUT_FILENAME     = "output_filename";
   public static final String OUTPUT_FORMAT       = "output_format";

   public static final String COMMAND_LINE_PARAMS = "command_line_params";


   private static String sDefaultExecutableDir = "/usr/local/bin";
   private static String sDefaultExecutable    = "muscle";

   //###########################################################################
   // CONSTRUCTORS
   //###########################################################################

   //---------------------------------------------------------------------------
   public MuscleSettings()
   {
      super();
   }

   public MuscleSettings(XMLTag inXMLTag)
   {
      super(inXMLTag);
   }

   //---------------------------------------------------------------------------
   @Override
   protected void init()
   {
      add(new StringSetting(EXECUTABLE_DIR, sDefaultExecutableDir));
      add(new StringSetting(EXECUTABLE, sDefaultExecutable));
      add(new StringSetting(INPUT_FILENAME));
      add(new StringSetting(OUTPUT_FILENAME));
      add(new StringSetting(OUTPUT_FORMAT));

      add(new StringSetting(COMMAND_LINE_PARAMS));
   }

   //###########################################################################
   // PUBLIC METHODS
   //###########################################################################

   //---------------------------------------------------------------------------
   public static void setDefaultExecutableDir(File inValue)
   {
      sDefaultExecutableDir = inValue.getPath();
   }

   //---------------------------------------------------------------------------
   public static File getDefaultExecutableDir()
   {
      return new File(sDefaultExecutableDir);
   }

   //---------------------------------------------------------------------------
   public static void setDefaultExecutable(String inValue)
   {
      sDefaultExecutable = inValue;
   }

   //---------------------------------------------------------------------------
   public static String getDefaultExecutable()
   {
      return sDefaultExecutable;
   }


   //---------------------------------------------------------------------------
   public File getExecutableDir()
   {
      File executableDir = null;

      String stringValue = get(EXECUTABLE_DIR).getStringValue();
      if (StringUtil.isSet(stringValue))
      {
         executableDir = new File(stringValue);
      }

      return executableDir;
   }

   //---------------------------------------------------------------------------
   @SuppressWarnings("unchecked")
   public MuscleSettings setExecutableDir(File inValue)
   {
      get(EXECUTABLE_DIR).setValue(inValue != null ? inValue.getAbsolutePath() : null);
      return this;
   }

   //---------------------------------------------------------------------------
   public String getExecutable()
   {
      return get(EXECUTABLE).getStringValue();
   }

   //---------------------------------------------------------------------------
   @SuppressWarnings("unchecked")
   public MuscleSettings setExecutable(String inValue)
   {
      get(EXECUTABLE).setValue(inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   public File getInputFile()
   {
      File file = null;

      String stringValue = get(INPUT_FILENAME).getStringValue();
      if (StringUtil.isSet(stringValue))
      {
         file = new File(stringValue);
      }

      return file;
   }

   //---------------------------------------------------------------------------
   @SuppressWarnings("unchecked")
   public MuscleSettings setInputFile(File inValue)
   {
      get(INPUT_FILENAME).setValue(inValue != null ? inValue.getAbsolutePath() : null);
      return this;
   }


   //---------------------------------------------------------------------------
   public File getOutputFile()
   {
      File file = null;

      String stringValue = get(OUTPUT_FILENAME).getStringValue();
      if (StringUtil.isSet(stringValue))
      {
         file = new File(stringValue);
      }

      return file;
   }

   //---------------------------------------------------------------------------
   @SuppressWarnings("unchecked")
   public MuscleSettings setOutputFile(File inValue)
   {
      get(OUTPUT_FILENAME).setValue(inValue != null ? inValue.getAbsolutePath() : null);
      return this;
   }

   //---------------------------------------------------------------------------
   public MuscleOutputFormat getOutputFormat()
   {
      MuscleOutputFormat value = null;

      String stringValue = get(OUTPUT_FORMAT).getStringValue();
      if (StringUtil.isSet(stringValue))
      {
         value = MuscleOutputFormat.valueOf(stringValue);
      }

      return value;
   }

   //---------------------------------------------------------------------------
   @SuppressWarnings("unchecked")
   public MuscleSettings setOutputFormat(MuscleOutputFormat inValue)
   {
      get(OUTPUT_FORMAT).setValue(inValue != null ? inValue.name() : null);
      return this;
   }


   //---------------------------------------------------------------------------
   public String getCommandLineParams()
   {
      return (String) get(COMMAND_LINE_PARAMS).getValue();
   }

   //---------------------------------------------------------------------------
   /**
    Additional (optional) command line parameters for the end of the Muscle command
    @param inValue the additional command line parameters to be appended to the end of the command
    @return this Settings object to enable chaining
    */
   @SuppressWarnings("unchecked")
   public MuscleSettings setCommandLineParams(String inValue)
   {
      get(COMMAND_LINE_PARAMS).setValue(inValue);
      return this;
   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy