public static String protdist(String query, String model, String GammaDistrOfRates,
            double CoeffOfVariation, double fracOfInvSites, String oneCatOfSubRates,
            int noOfCat, String rateForEachCat, String categoriesFile, String UseWts4Posn, String weightsFile,
            String analyzeMultipleDataSets, String DataWeights, int noOfMultipleDataSets, String inputSequencesInterleaved, 
            double transitionTransversion, String baseFreq, double ProbChangeCat, String geneticCode, String catOfAminoAcids) throws ImproperInputEx
    {
        GetAbsolutePath pt = new GetAbsolutePath();
        String absolutePath = pt.getPath();
        
        String output = "";
        if (query.equals(""))
        {
            throw new ImproperInputEx("Job not Submitted: Query Cannot be Null");
        }
        
        try
        {
            //Are the inputs entered valid
            boolean check =
                    verify(model, GammaDistrOfRates, CoeffOfVariation, fracOfInvSites,
                    oneCatOfSubRates, noOfCat, rateForEachCat, categoriesFile, UseWts4Posn, weightsFile,
                    analyzeMultipleDataSets, DataWeights, noOfMultipleDataSets, inputSequencesInterleaved,
                    transitionTransversion,baseFreq, ProbChangeCat, geneticCode, catOfAminoAcids);
            if (check)
            {
                //Create a new Directory for Current request in tmp folder
                String dirName = "PhylipProtdist:" + UUID.randomUUID().toString();
                String dirNamePath = absolutePath + dirName;
                boolean success = (new File(dirNamePath)).mkdir();
                if (success)
                {
                    System.out.println("Directory: " + dirNamePath + " created");
                } else
                {
                    System.out.println("Directory: " + dirNamePath + " Could not be created");
                }
                //to do in esle throw a user defined exception, so that execution haults beyond this point

                FileWriter f = new FileWriter(dirNamePath + "/query.txt");
                BufferedWriter w = new BufferedWriter(f);
                w.write(query);
                w.close();
                
                if (categoriesFile.length() > 0)
                {
                    f = new FileWriter(dirNamePath + "/categories");
                    BufferedWriter w1 = new BufferedWriter(f);
                    w1.write(categoriesFile);
                    w1.close();

                }
                
                if (weightsFile.length() > 0)
                {
                    f = new FileWriter(dirNamePath + "/weights");
                    BufferedWriter w2 = new BufferedWriter(f);
                    w2.write(weightsFile);
                    w2.close();
                }

                //Create .sh file in the newly created Dir
                String partCode = partCodeG;
                partCode +="y\n";
                partCode += restCode;

                String code = "#!/bin/bash\n"
                        + "cd " + dirNamePath + "\n"
                        + "phylip protdist >>op.txt <<EOD\n"
                        + "query.txt\n"
                        + partCode
                        + "EOD";

                f = new FileWriter(dirNamePath + "/protdist.sh");
                BufferedWriter ww = new BufferedWriter(f);
                ww.write(code);
                ww.close();
                Runtime rt = Runtime.getRuntime();
                Process p = rt.exec("sh " + dirNamePath + "/protdist.sh");

                output = dirName;
            }//end if
            else
            {
                throw new ImproperInputEx(errorMsg);
            }//end else


        } 
        catch (ImproperInputEx ex)
        {
            throw new ImproperInputEx("Program failed due to : " + ex);
        }//catch
        catch (Exception e)
        {
            throw new UnexpectedErrorEx(e.getMessage());
        }//catch 
        finally
        {
            return output;
        }

    }