IMPACT
Class Utilities

java.lang.Object
  extended by IMPACT.Utilities

public class Utilities
extends java.lang.Object

Implementation of various methods and data structures needed across IMPACT package.

Author:
Emanuel Maldonado

Field Summary
static java.lang.String AAI1URL_KEY
          Key for access FTP value for AAindex1 DB download/update
 java.lang.String AAINDEX1_PARAMVALUE
          Biochemical Properties - AAindex1
Important Name for use in parameter name whenever use of an AAindex1 property is needed.
static java.lang.String ABOUTLBLS_RESOURCE_PATH
          about labels text file path from IMPACT.resources
static java.lang.String ABOUTTXT_RESOURCE_PATH
          about text file path from IMPACT.resources
static java.lang.String[] ALPHABETS
          Alphabets supported in Contest
static java.lang.String[] AMINOACIDS
          Aminoacids models
static java.lang.String ATV_KEY
          Key for access ATV executable absolute location
static java.lang.String BASEPATH_KEY
          Key for access base path for all other locations
static char BP
          Identifier for Biochemical Properties hashtable
static java.lang.String CONTEST_KEY
          Key for access ConTest executable absolute location
static java.lang.String DATASETBASE_KEY
          Key for access Data Sets location
static java.lang.String DATASETNAME_KEY
          Key for access specific Data Set location
static char DL
          Identifier for Data Loading hashtable
static java.lang.String DSCONTEST_DIR
          Directory name for ConTest data set name subdirectory
static java.lang.String DSCONTEST_KEY
          Key for access ConTest location directory in specific Data Set
static java.lang.String DSPHYLOGENY_DIR
          Directory name for Phylogeny data set name subdirectory
static java.lang.String DSPHYLOGENY_KEY
          Key for access Phylogeny location directory in specific Data Set
static java.lang.String DSRESULTS_DIR
          Directory name for Results data set name subdirectory
static java.lang.String DSRESULTS_KEY
          Key for access Results location directory in specific Data Set
static java.lang.String DSSEQUENCES_DIR
          Directory name for Sequences data set name subdirectory
static java.lang.String DSSEQUENCES_KEY
          Key for access Sequences location directory in specific Data Set
static java.lang.String DSSTRUCTURE_DIR
          Directory name for Structure data set name subdirectory
static java.lang.String DSSTRUCTURE_KEY
          Key for access Structure location directory in specific Data Set
static java.lang.String GUIPATH_KEY
          Key for access GUI directory location
static java.lang.String IMAGE_ICON_RESOURCE_PATH
          image icon path from IMPACT.resources
static java.lang.String INTERNPROGS_KEY
          Key for access External Programs directory location
static java.lang.String JMOL_KEY
          Key for access Jmol executable absolute location
static char MS
          Identifier for Model Specification hashtable
static java.lang.String OPTIONSFILE_F
          ConTest Options file Format
static char OPTIONSFILE_TYPE
          ConTest Options file Type
static char OT
          Identifier for Output hashtable
static java.lang.String PDFVIEWER_KEY
          Key for access PDF viewer absolute location
static java.lang.String PHYML_KEY
          Key for access PhyML executable absolute location
static java.lang.String PSVIEWER_KEY
          Key for access PS viewer absolute location
static java.lang.String R_OPTIONSFILE_F
          R software Options file Format
static char R_OPTIONSFILE_TYPE
          R software Options file Type
static java.lang.String RESIDUE_LOCTXT_RESOURCE_PATH
          residues location example file path from IMPACT.resources
static java.lang.String REXE_KEY
          Key for access R executable absolute location
static java.lang.String RSCRIPTS_KEY
          Key for access R scripts executables absolute location
 
Constructor Summary
Utilities()
          Initialize and access several Utilities.
 
Method Summary
 java.lang.String buildROptionsToFile()
          Build format for R options.
 boolean downloadFile(java.lang.String uurl, java.io.File tmpout)
          Download file pointed by url to file.
 java.lang.String firstCharUp(java.lang.String txt)
          Get given string with only first character to upper case.
Remaining part to lower case.
 java.lang.String generateNewTmpRMainFile()
          Generates a new copy of main R script file, ignoring options and replacing source("_file_") lines with lines where the _file_ has absolute path and that matches main file absolute path i.e.
 java.lang.String getAAindex1PropertyName()
          Get AAIndex1 property name.
This is obtained from AAIndex1 file field D [property name] (ref).
File must first have been read (successfully).
 java.lang.String getAAindex1URL()
          Get URL for AAindex1 DB download file.
 java.io.BufferedReader getBR(java.lang.String filepath)
          Get Buffered Reader for file reading.
 java.lang.String getExt(java.lang.String filename)
          Get filename extension.
 java.lang.String getFileContent(java.io.InputStream file)
          Get content of file, by input stream.
 java.lang.String getFilePathByValue(java.lang.String value)
          Get Property file path given value of same file.
 java.lang.String getFormatByExt(java.lang.String flname)
          Get format of file based on its extension.
 java.lang.String getHashTableValueByIndex(char accessTable, int index)
          Get value given specific hashtable and index.
 java.lang.String getHashTableValueByKey(char accessTable, java.lang.String key)
          Get value given specific hashtable and key.
 java.lang.String getInternalParameters()
          Get internal values to print.
 java.lang.String getLocation(java.lang.String location_key)
          Get location (hashtable value) path, given key from.
 java.lang.String getName(java.lang.String path)
          Get name of file given absolute path.
For opposite see also.
 java.lang.String getNameNoExt(java.lang.String pathtofile)
          Remove extension from filename with extension, given absolute path to filename.
 java.lang.String getNewGenFile(java.lang.String filePath, java.lang.String fileName)
          For given file absolute path (with no name), calculates new name until it is found not to exist.
If it is needed (>99) number of generation IDs may be extended.
 int getNumOfProp()
          Get number of properties found in file.
 java.lang.String getPathNoName(java.lang.String path)
          Get path without directory name, given absolute path.
For opposite see also.
 int getPropIndexByPath(java.lang.String path)
          Get Index for property contained in given file path.
 int getPropIndexByValue(java.lang.String value)
          Get Index for property matching given value.
 java.lang.String getPropNameByIndex(int index)
          Get property name given index.
 java.lang.String[] getPropNames()
          Get list of properties names.
 java.lang.String getROption(java.lang.String key)
          Get option for specified key.
 java.lang.String[] getRScriptVarNames()
          Read options section and get variables names.
Only executes completely for the first time, when names are no set.
Variable names are returned in same order that appear in the script.
 java.lang.String getSubstrChopFst(java.lang.String txt)
          Get substring without first character.
 java.lang.String getSubstrChopLast(java.lang.String txt)
          Get substring without last charater.
 java.lang.String getSubstringByChar(java.lang.String text, java.lang.String ch)
          Get substring from text given char.
The final string consists of all characters between 0 and index of that character.
 void initHashTbls()
          Initialize ConTest parameters in all hashtables with empty values and specific keys.
DL (DataLoading), MS (Model Specificaftion), BP (Biochemical Properties), OT(Ouput)
 void initROptionsTable(java.lang.String[] keys)
          Initialize R Options table with given keys to empty values.
 boolean isProperAAi1File(java.lang.String filepath)
          Gives a strong hint about a file being an AAindex1 file.
 boolean pathExists(java.lang.String flpath)
          Verify if path exists recursively.
This method mounts the whole path starting at the root, and verifies at each point (name of directory) of the path if the whole exists, if not returns false;
 java.lang.String readAAIndex1Properties(java.lang.String aaindex1file)
          Read AAIndex1 file and obtain property name.
AAIndex1 file is verified for proper file, during process.
 java.lang.String[] readBppMLStatFile(java.lang.String bppstatFile)
          Read BppML stat files (*params.txt).
Get values for Number of categories and Gamma shape parameter.
 boolean readOptionsFile(java.lang.String filepath)
          Read file into hashtables.
Skips commented lines with #, // and block comments /*...*'/'
Block comments have precedence over the others.
 java.lang.String[] readPhyMLStatFile(java.lang.String phystatFile)
          Read PhyML stat files (*phyml_stat.txt).
Get values for Number of categories and Gamma shape parameter.
 boolean readPrefsFromFile(boolean finalFile)
          If file for preferences exists, use its values to present to user instead of ones by default behaviour found by Utilities.
 void readROptionsFile(java.lang.String r_optsfile)
          Read R options from file.
 void removeRTmpFiles()
          Delete R temporary files used for execution.
 boolean renameFile(java.lang.String source, java.lang.String dest, boolean deletesrc)
          Copies content from source file to destination file.
This way creating a rename operation.
This was created to overcome limitations of File.renameTo() method.
Replaces any destination file that may exist.
 void replaceBPFileParameterW(java.lang.String numProp)
          Replace parameter properties.fileNUM existent in BP table for new key with new NUM.
Used when writing options to file.
 java.lang.String replaceExt(java.lang.String filename, java.lang.String format)
          Replace extension with one based on given format.
 java.lang.String replaceExtBy(java.lang.String filename, java.lang.String newExt)
          Replace extension with new given extension.
 void setAAindex1URL(java.lang.String url)
          Set URL value for AAindex1 DB given by user.
 java.lang.String setExt(java.lang.String flname, java.lang.String format)
          Add an extension to file name, according to given format.
 void setHashTableValueByIndex(char accessTable, int index, java.lang.String value)
          Set hashtable value for specified index and accessTable.
 void setLocation(java.lang.String location_key, java.lang.String value)
          Set location value for Locations hashtable, given key field at
 void setROption(java.lang.String key, java.lang.String option)
          Set option to specified key.
 void updateBPTablesParams(int aintProps, int numOfFiles)
          For more than one biochemical property from AAindex1 DB, more parameters are required to support those files.
 boolean updateDataSetLocation(java.lang.String optsFilePath)
          Update data set information in Locations table through given specific Data Set Name path.
If the data set name is not different from the one in table, does nothing.
 java.lang.String writeInternalParametersToFile()
          Print internal parameters to file located in BASE_DIR.
 void writeOptionsToFile(java.lang.String filepath)
          Write hashtables to file.
 void writePrefsToFile(boolean finalFile)
          Write Preferences to file, for future sessions.
Allows writing for temporary file meant for Preferences window.
This is used to allow the user to recover old values that might be changed during session.
 java.lang.String writeROptionsToFile(java.lang.String optionsR, java.lang.String filepath)
          Save R Options to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DL

public static final char DL
Identifier for Data Loading hashtable

See Also:
Constant Field Values

MS

public static final char MS
Identifier for Model Specification hashtable

See Also:
Constant Field Values

BP

public static final char BP
Identifier for Biochemical Properties hashtable

See Also:
Constant Field Values

OT

public static final char OT
Identifier for Output hashtable

See Also:
Constant Field Values

BASEPATH_KEY

public static final java.lang.String BASEPATH_KEY
Key for access base path for all other locations

See Also:
Constant Field Values

DATASETBASE_KEY

public static final java.lang.String DATASETBASE_KEY
Key for access Data Sets location

See Also:
Constant Field Values

DATASETNAME_KEY

public static final java.lang.String DATASETNAME_KEY
Key for access specific Data Set location

See Also:
Constant Field Values

DSCONTEST_KEY

public static final java.lang.String DSCONTEST_KEY
Key for access ConTest location directory in specific Data Set

See Also:
Constant Field Values

DSPHYLOGENY_KEY

public static final java.lang.String DSPHYLOGENY_KEY
Key for access Phylogeny location directory in specific Data Set

See Also:
Constant Field Values

DSRESULTS_KEY

public static final java.lang.String DSRESULTS_KEY
Key for access Results location directory in specific Data Set

See Also:
Constant Field Values

DSSEQUENCES_KEY

public static final java.lang.String DSSEQUENCES_KEY
Key for access Sequences location directory in specific Data Set

See Also:
Constant Field Values

DSSTRUCTURE_KEY

public static final java.lang.String DSSTRUCTURE_KEY
Key for access Structure location directory in specific Data Set

See Also:
Constant Field Values

GUIPATH_KEY

public static final java.lang.String GUIPATH_KEY
Key for access GUI directory location

See Also:
Constant Field Values

INTERNPROGS_KEY

public static final java.lang.String INTERNPROGS_KEY
Key for access External Programs directory location

See Also:
Constant Field Values

CONTEST_KEY

public static final java.lang.String CONTEST_KEY
Key for access ConTest executable absolute location

See Also:
Constant Field Values

PHYML_KEY

public static final java.lang.String PHYML_KEY
Key for access PhyML executable absolute location

See Also:
Constant Field Values

ATV_KEY

public static final java.lang.String ATV_KEY
Key for access ATV executable absolute location

See Also:
Constant Field Values

RSCRIPTS_KEY

public static final java.lang.String RSCRIPTS_KEY
Key for access R scripts executables absolute location

See Also:
Constant Field Values

JMOL_KEY

public static final java.lang.String JMOL_KEY
Key for access Jmol executable absolute location

See Also:
Constant Field Values

REXE_KEY

public static final java.lang.String REXE_KEY
Key for access R executable absolute location

See Also:
Constant Field Values

PDFVIEWER_KEY

public static final java.lang.String PDFVIEWER_KEY
Key for access PDF viewer absolute location

See Also:
Constant Field Values

PSVIEWER_KEY

public static final java.lang.String PSVIEWER_KEY
Key for access PS viewer absolute location

See Also:
Constant Field Values

AAI1URL_KEY

public static final java.lang.String AAI1URL_KEY
Key for access FTP value for AAindex1 DB download/update

See Also:
Constant Field Values

OPTIONSFILE_TYPE

public static final char OPTIONSFILE_TYPE
ConTest Options file Type

See Also:
Constant Field Values

OPTIONSFILE_F

public static final java.lang.String OPTIONSFILE_F
ConTest Options file Format

See Also:
Constant Field Values

R_OPTIONSFILE_TYPE

public static final char R_OPTIONSFILE_TYPE
R software Options file Type

See Also:
Constant Field Values

R_OPTIONSFILE_F

public static final java.lang.String R_OPTIONSFILE_F
R software Options file Format

See Also:
Constant Field Values

DSCONTEST_DIR

public static final java.lang.String DSCONTEST_DIR
Directory name for ConTest data set name subdirectory


DSPHYLOGENY_DIR

public static final java.lang.String DSPHYLOGENY_DIR
Directory name for Phylogeny data set name subdirectory


DSRESULTS_DIR

public static final java.lang.String DSRESULTS_DIR
Directory name for Results data set name subdirectory


DSSEQUENCES_DIR

public static final java.lang.String DSSEQUENCES_DIR
Directory name for Sequences data set name subdirectory


DSSTRUCTURE_DIR

public static final java.lang.String DSSTRUCTURE_DIR
Directory name for Structure data set name subdirectory


AMINOACIDS

public static java.lang.String[] AMINOACIDS
Aminoacids models


ALPHABETS

public static java.lang.String[] ALPHABETS
Alphabets supported in Contest


IMAGE_ICON_RESOURCE_PATH

public static java.lang.String IMAGE_ICON_RESOURCE_PATH
image icon path from IMPACT.resources


RESIDUE_LOCTXT_RESOURCE_PATH

public static java.lang.String RESIDUE_LOCTXT_RESOURCE_PATH
residues location example file path from IMPACT.resources


ABOUTTXT_RESOURCE_PATH

public static java.lang.String ABOUTTXT_RESOURCE_PATH
about text file path from IMPACT.resources


ABOUTLBLS_RESOURCE_PATH

public static java.lang.String ABOUTLBLS_RESOURCE_PATH
about labels text file path from IMPACT.resources


AAINDEX1_PARAMVALUE

public final java.lang.String AAINDEX1_PARAMVALUE
Biochemical Properties - AAindex1
Important Name for use in parameter name whenever use of an AAindex1 property is needed. This is used in conjuntion with parameter file specifying the file containing that property.

See Also:
Constant Field Values
Constructor Detail

Utilities

public Utilities()
Initialize and access several Utilities.

Method Detail

readPrefsFromFile

public boolean readPrefsFromFile(boolean finalFile)
If file for preferences exists, use its values to present to user instead of ones by default behaviour found by Utilities.

Parameters:
finalFile - if true reads from persistent file; otherwise from temporary file.
Returns:
returns true if file has correct structure, or false otherwise.
See Also:
writePrefsToFile(boolean), GUIConfPreferences

writePrefsToFile

public void writePrefsToFile(boolean finalFile)
Write Preferences to file, for future sessions.
Allows writing for temporary file meant for Preferences window.
This is used to allow the user to recover old values that might be changed during session.

Parameters:
finalFile - if true writes to definite file; otherwise writes to temporary file.
See Also:
GUIConfPreferences

updateDataSetLocation

public boolean updateDataSetLocation(java.lang.String optsFilePath)
Update data set information in Locations table through given specific Data Set Name path.
If the data set name is not different from the one in table, does nothing.

Parameters:
optsFilePath - the path of the options file from where to get Data Set Name
Returns:
true if success; false otherwise.
See Also:
getDataSetName(java.lang.String)

getLocation

public java.lang.String getLocation(java.lang.String location_key)
Get location (hashtable value) path, given key from.

Parameters:
location_key - hashtable key to access path. Possible values see below.
Returns:
absolute path for key location (if exists); or null otherwise.
See Also:
BASEPATH_KEY, DATASETBASE_KEY, DATASETNAME_KEY, DSCONTEST_KEY, DSPHYLOGENY_KEY, DSRESULTS_KEY, DSSEQUENCES_KEY, DSSTRUCTURE_KEY, GUIPATH_KEY, INTERNPROGS_KEY, CONTEST_KEY, PHYML_KEY, ATV_KEY, RSCRIPTS_KEY, JMOL_KEY

setLocation

public void setLocation(java.lang.String location_key,
                        java.lang.String value)
Set location value for Locations hashtable, given key field at

Parameters:
location_key - to access specific location.
value - absolute path for key location that MUST exist, or value will not be set.
See Also:
BASEPATH_KEY, DATASETBASE_KEY, DATASETNAME_KEY, DSCONTEST_KEY, DSPHYLOGENY_KEY, DSRESULTS_KEY, DSSEQUENCES_KEY, DSSTRUCTURE_KEY, GUIPATH_KEY, INTERNPROGS_KEY, CONTEST_KEY, PHYML_KEY, ATV_KEY, RSCRIPTS_KEY, JMOL_KEY

getInternalParameters

public java.lang.String getInternalParameters()
Get internal values to print.

Returns:
parameters

writeInternalParametersToFile

public java.lang.String writeInternalParametersToFile()
Print internal parameters to file located in BASE_DIR.

Returns:
absolute file path location.

initHashTbls

public void initHashTbls()
Initialize ConTest parameters in all hashtables with empty values and specific keys.
DL (DataLoading), MS (Model Specificaftion), BP (Biochemical Properties), OT(Ouput)

See Also:
DL, MS, BP, OT

getHashTableValueByIndex

public java.lang.String getHashTableValueByIndex(char accessTable,
                                                 int index)
Get value given specific hashtable and index.

Parameters:
accessTable - may take the values DL, MS, PE, BP, OT (ignorecase).
index - identifier for the wanted hashtable value.
Returns:
specified hashtable value for index
See Also:
setHashTableValueByIndex(char, int, java.lang.String), setHashTableValueByKey(char, java.lang.String, java.lang.String), DL, MS, BP, OT

getHashTableValueByKey

public java.lang.String getHashTableValueByKey(char accessTable,
                                               java.lang.String key)
Get value given specific hashtable and key.

Parameters:
accessTable - may take the values DL, MS, PE, BP, OT (ignorecase).
key - identifier for the wanted hashtable value.
Returns:
specified hashtable value for key
See Also:
setHashTableValueByIndex(char, int, java.lang.String), setHashTableValueByKey(char, java.lang.String, java.lang.String), DL, MS, BP, OT

setHashTableValueByIndex

public void setHashTableValueByIndex(char accessTable,
                                     int index,
                                     java.lang.String value)
Set hashtable value for specified index and accessTable.

Parameters:
accessTable - may take the values DL, MS, PE, BP, OT (ignorecase).
index - identifier for the wanted hashtable field where to place value.
value - value for index identifier
See Also:
getHashTableValueByIndex(char, int), getHashTableValueByKey(char, java.lang.String), DL, MS, BP, OT

updateBPTablesParams

public void updateBPTablesParams(int aintProps,
                                 int numOfFiles)
For more than one biochemical property from AAindex1 DB, more parameters are required to support those files. This will fabricate remaining parameters and reinitialize corresponding tables.

Parameters:
aintProps - number of (ConTest) internal properties chosen. Maximum 3.
numOfFiles - number that will specify how many more parameters are required.

getSubstrChopLast

public java.lang.String getSubstrChopLast(java.lang.String txt)
Get substring without last charater.

Parameters:
txt -
Returns:
substring (tx)

getSubstrChopFst

public java.lang.String getSubstrChopFst(java.lang.String txt)
Get substring without first character.

Parameters:
txt -
Returns:
substring (xt)

getSubstringByChar

public java.lang.String getSubstringByChar(java.lang.String text,
                                           java.lang.String ch)
Get substring from text given char.
The final string consists of all characters between 0 and index of that character.

Parameters:
text - from where to search and get final result.
ch - the character to search.
Returns:
substring from 0 to index of char (excluding char); or emtpy string "", if not found.

firstCharUp

public java.lang.String firstCharUp(java.lang.String txt)
Get given string with only first character to upper case.
Remaining part to lower case.

Parameters:
txt -
Returns:
Txt ; if txt is null or empty, empty is returned.

getName

public java.lang.String getName(java.lang.String path)
Get name of file given absolute path.
For opposite see also.

Parameters:
path - file (absolute) path
Returns:
name of directory (chopped path)
See Also:
getPathNoName(String path)

getPathNoName

public java.lang.String getPathNoName(java.lang.String path)
Get path without directory name, given absolute path.
For opposite see also.

Parameters:
path -
Returns:
path only (chopped name)
See Also:
getName(String path)

getExt

public java.lang.String getExt(java.lang.String filename)
Get filename extension.

Parameters:
filename - with extension.
Returns:
extension without '.' ; null if filename has no extension.

replaceExt

public java.lang.String replaceExt(java.lang.String filename,
                                   java.lang.String format)
Replace extension with one based on given format.

Parameters:
filename - without extension.
format - matching the extension.
Returns:
filename with extension.

replaceExtBy

public java.lang.String replaceExtBy(java.lang.String filename,
                                     java.lang.String newExt)
Replace extension with new given extension.

Parameters:
filename - with extension.
newExt - of the new extension.
Returns:
filename with new extension.

getNameNoExt

public java.lang.String getNameNoExt(java.lang.String pathtofile)
Remove extension from filename with extension, given absolute path to filename.

Parameters:
pathtofile - with extension
Returns:
filename without extension excluding the dot; or filename if no extension.

setExt

public java.lang.String setExt(java.lang.String flname,
                               java.lang.String format)
Add an extension to file name, according to given format.

Parameters:
flname - file to add an extension.
format - format of file. May be FASTA, MASE, PHYLIP(I|S), CLUSTAL, DCSE, ConTest options and R options file.
Returns:
same file name with extension. If file or format empty or null, null is returned.
See Also:
FileFormatConverter.FASTA_F, FileFormatConverter.MASE_F, FileFormatConverter.PHYLIPI_F, FileFormatConverter.PHYLIPS_F, FileFormatConverter.CLUSTAL_F, OPTIONSFILE_F, R_OPTIONSFILE_F

getFormatByExt

public java.lang.String getFormatByExt(java.lang.String flname)
Get format of file based on its extension.

Parameters:
flname - file name with extension.
Returns:
format or null if file name has no extension or is not correct.
See Also:
FileFormatConverter.FASTA_F, FileFormatConverter.MASE_F, FileFormatConverter.PHYLIPI_F, FileFormatConverter.PHYLIPS_F, FileFormatConverter.CLUSTAL_F

getNewGenFile

public java.lang.String getNewGenFile(java.lang.String filePath,
                                      java.lang.String fileName)
For given file absolute path (with no name), calculates new name until it is found not to exist.
If it is needed (>99) number of generation IDs may be extended.

Parameters:
filePath - path of file (only directory(ies)).
fileName - name of file with extension.
Returns:
new generated absolute file path that does not exist. With same extension.

pathExists

public boolean pathExists(java.lang.String flpath)
Verify if path exists recursively.
This method mounts the whole path starting at the root, and verifies at each point (name of directory) of the path if the whole exists, if not returns false;

Parameters:
flpath - directory absolute path.
Returns:
true if the whole path exists; false, at the first piece that does not exist.

getBR

public java.io.BufferedReader getBR(java.lang.String filepath)
Get Buffered Reader for file reading.

Parameters:
filepath - absolute path for file.
Returns:
br Buffered Reader

renameFile

public boolean renameFile(java.lang.String source,
                          java.lang.String dest,
                          boolean deletesrc)
Copies content from source file to destination file.
This way creating a rename operation.
This was created to overcome limitations of File.renameTo() method.
Replaces any destination file that may exist.

Parameters:
source - absolute path to source file from where to get contents.
dest - absolute path to destination file where to copy contents.
deletesrc - if true delete source file; otherwise maintain file.
Returns:
true if success; false, otherwise.

readAAIndex1Properties

public java.lang.String readAAIndex1Properties(java.lang.String aaindex1file)
Read AAIndex1 file and obtain property name.
AAIndex1 file is verified for proper file, during process.

Parameters:
aaindex1file - absolute path
Returns:
file content; or null if not an AAIndex1 database file.

getAAindex1PropertyName

public java.lang.String getAAindex1PropertyName()
Get AAIndex1 property name.
This is obtained from AAIndex1 file field D [property name] (ref).
File must first have been read (successfully).

Returns:
property name; or null if reading was not successfull.
See Also:
readAAIndex1Properties(java.lang.String)

readOptionsFile

public boolean readOptionsFile(java.lang.String filepath)
Read file into hashtables.
Skips commented lines with #, // and block comments /*...*'/'
Block comments have precedence over the others.

Parameters:
filepath - file to read from.
Returns:
true if successfull; false otherwise.

replaceBPFileParameterW

public void replaceBPFileParameterW(java.lang.String numProp)
Replace parameter properties.fileNUM existent in BP table for new key with new NUM.
Used when writing options to file.

Parameters:
numProp - the total number of properties (NUM)

writeOptionsToFile

public void writeOptionsToFile(java.lang.String filepath)
Write hashtables to file.

Parameters:
filepath - file were to write.

readPhyMLStatFile

public java.lang.String[] readPhyMLStatFile(java.lang.String phystatFile)
Read PhyML stat files (*phyml_stat.txt).
Get values for Number of categories and Gamma shape parameter.

Parameters:
phystatFile - phyml stat file absolute path.
Returns:
values if file expected ; null if file with wrong specification or not expected (values not found).

readBppMLStatFile

public java.lang.String[] readBppMLStatFile(java.lang.String bppstatFile)
Read BppML stat files (*params.txt).
Get values for Number of categories and Gamma shape parameter.

Parameters:
bppstatFile - phyml stat file absolute path.
Returns:
values if file expected ; null if file with wrong specification or not expected (values not found).

generateNewTmpRMainFile

public java.lang.String generateNewTmpRMainFile()
Generates a new copy of main R script file, ignoring options and replacing source("_file_") lines with lines where the _file_ has absolute path and that matches main file absolute path i.e. have same location.

Options are ignored until it finds read.table() R function.
And from there on, is assumed options section is terminated and at the "not editable part" starts.
So all source("_file_") lines found in the "not editable part" are replaced.

Returns:
new temporary generated file.
See Also:
writeROptionsToFile(java.lang.String, java.lang.String)

getRScriptVarNames

public java.lang.String[] getRScriptVarNames()
Read options section and get variables names.
Only executes completely for the first time, when names are no set.
Variable names are returned in same order that appear in the script.

Returns:
R_VARNAMES; or null in case R main script does not exist.

initROptionsTable

public void initROptionsTable(java.lang.String[] keys)
Initialize R Options table with given keys to empty values.

Parameters:
keys -

setROption

public void setROption(java.lang.String key,
                       java.lang.String option)
Set option to specified key.

Parameters:
key - that must exists in order to set option.
option - value associated.

getROption

public java.lang.String getROption(java.lang.String key)
Get option for specified key.

Parameters:
key - identify which value.
Returns:
option if key exists; or null otherwise.

readROptionsFile

public void readROptionsFile(java.lang.String r_optsfile)
Read R options from file. Must have initialized R Options table.

Parameters:
r_optsfile - r options absolute file path.
See Also:
initROptionsTable(java.lang.String[])

buildROptionsToFile

public java.lang.String buildROptionsToFile()
Build format for R options.

Returns:
r options formatted

writeROptionsToFile

public java.lang.String writeROptionsToFile(java.lang.String optionsR,
                                            java.lang.String filepath)
Save R Options to file.

Parameters:
optionsR - options.
filepath - specified absolute file path to save in. If null used for execution; acts using temporary files.
Returns:
filepath used.
See Also:
generateNewTmpRMainFile()

removeRTmpFiles

public void removeRTmpFiles()
Delete R temporary files used for execution.


getFileContent

public java.lang.String getFileContent(java.io.InputStream file)
Get content of file, by input stream.

Parameters:
file - input stream.
Returns:
content.

downloadFile

public boolean downloadFile(java.lang.String uurl,
                            java.io.File tmpout)
Download file pointed by url to file.

Parameters:
uurl - user url from where to download file.
tmpout - file where contents will be saved.
Returns:
true in case of success; false, otherwise.

isProperAAi1File

public boolean isProperAAi1File(java.lang.String filepath)
Gives a strong hint about a file being an AAindex1 file.

Parameters:
filepath - AAindex1 file path.
Returns:
true if it founds consistent with AAindex1 format; or false, otherwise.

getPropNames

public java.lang.String[] getPropNames()
Get list of properties names.

Returns:
the list of properties names.

getNumOfProp

public int getNumOfProp()
Get number of properties found in file.

Returns:
number of properties; or -1 if no properties found.

getPropIndexByValue

public int getPropIndexByValue(java.lang.String value)
Get Index for property matching given value.

Parameters:
value - to search for.
Returns:
Index of given value; or -1 if value is not found.

getPropIndexByPath

public int getPropIndexByPath(java.lang.String path)
Get Index for property contained in given file path.

Parameters:
path - to search for.
Returns:
Index of given path; or -1 if path does not exist.

getPropNameByIndex

public java.lang.String getPropNameByIndex(int index)
Get property name given index.

Parameters:
index - of property.
Returns:
name of property; or null if index out of range.

getFilePathByValue

public java.lang.String getFilePathByValue(java.lang.String value)
Get Property file path given value of same file.

Parameters:
value - from file; which is the description ('D ' field).
Returns:
path of file containing value; or null if value not found.

getAAindex1URL

public java.lang.String getAAindex1URL()
Get URL for AAindex1 DB download file.

Returns:
url.

setAAindex1URL

public void setAAindex1URL(java.lang.String url)
Set URL value for AAindex1 DB given by user.

Parameters:
url -