|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectIMPACT.Utilities
public class Utilities
Implementation of various methods and data structures needed across IMPACT package.
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 |
---|
public static final char DL
public static final char MS
public static final char BP
public static final char OT
public static final java.lang.String BASEPATH_KEY
public static final java.lang.String DATASETBASE_KEY
public static final java.lang.String DATASETNAME_KEY
public static final java.lang.String DSCONTEST_KEY
public static final java.lang.String DSPHYLOGENY_KEY
public static final java.lang.String DSRESULTS_KEY
public static final java.lang.String DSSEQUENCES_KEY
public static final java.lang.String DSSTRUCTURE_KEY
public static final java.lang.String GUIPATH_KEY
public static final java.lang.String INTERNPROGS_KEY
public static final java.lang.String CONTEST_KEY
public static final java.lang.String PHYML_KEY
public static final java.lang.String ATV_KEY
public static final java.lang.String RSCRIPTS_KEY
public static final java.lang.String JMOL_KEY
public static final java.lang.String REXE_KEY
public static final java.lang.String PDFVIEWER_KEY
public static final java.lang.String PSVIEWER_KEY
public static final java.lang.String AAI1URL_KEY
public static final char OPTIONSFILE_TYPE
public static final java.lang.String OPTIONSFILE_F
public static final char R_OPTIONSFILE_TYPE
public static final java.lang.String R_OPTIONSFILE_F
public static final java.lang.String DSCONTEST_DIR
public static final java.lang.String DSPHYLOGENY_DIR
public static final java.lang.String DSRESULTS_DIR
public static final java.lang.String DSSEQUENCES_DIR
public static final java.lang.String DSSTRUCTURE_DIR
public static java.lang.String[] AMINOACIDS
public static java.lang.String[] ALPHABETS
public static java.lang.String IMAGE_ICON_RESOURCE_PATH
public static java.lang.String RESIDUE_LOCTXT_RESOURCE_PATH
public static java.lang.String ABOUTTXT_RESOURCE_PATH
public static java.lang.String ABOUTLBLS_RESOURCE_PATH
public final java.lang.String AAINDEX1_PARAMVALUE
Constructor Detail |
---|
public Utilities()
Method Detail |
---|
public boolean readPrefsFromFile(boolean finalFile)
finalFile
- if true reads from persistent file; otherwise from temporary file.
writePrefsToFile(boolean)
,
GUIConfPreferences
public void writePrefsToFile(boolean finalFile)
finalFile
- if true writes to definite file; otherwise writes to temporary file.GUIConfPreferences
public boolean updateDataSetLocation(java.lang.String optsFilePath)
optsFilePath
- the path of the options file from where to get Data Set Name
getDataSetName(java.lang.String)
public java.lang.String getLocation(java.lang.String location_key)
location_key
- hashtable key to access path. Possible values see below.
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
public void setLocation(java.lang.String location_key, java.lang.String value)
location_key
- to access specific location.value
- absolute path for key location that MUST exist, or value will not be set.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
public java.lang.String getInternalParameters()
public java.lang.String writeInternalParametersToFile()
public void initHashTbls()
DL
,
MS
,
BP
,
OT
public java.lang.String getHashTableValueByIndex(char accessTable, int index)
accessTable
- may take the values DL, MS, PE, BP, OT (ignorecase).index
- identifier for the wanted hashtable value.
setHashTableValueByIndex(char, int, java.lang.String)
,
setHashTableValueByKey(char, java.lang.String, java.lang.String)
,
DL
,
MS
,
BP
,
OT
public java.lang.String getHashTableValueByKey(char accessTable, java.lang.String key)
accessTable
- may take the values DL, MS, PE, BP, OT (ignorecase).key
- identifier for the wanted hashtable value.
setHashTableValueByIndex(char, int, java.lang.String)
,
setHashTableValueByKey(char, java.lang.String, java.lang.String)
,
DL
,
MS
,
BP
,
OT
public void setHashTableValueByIndex(char accessTable, int index, java.lang.String value)
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 identifiergetHashTableValueByIndex(char, int)
,
getHashTableValueByKey(char, java.lang.String)
,
DL
,
MS
,
BP
,
OT
public void updateBPTablesParams(int aintProps, int numOfFiles)
aintProps
- number of (ConTest) internal properties chosen. Maximum 3.numOfFiles
- number that will specify how many more parameters are required.public java.lang.String getSubstrChopLast(java.lang.String txt)
txt
-
public java.lang.String getSubstrChopFst(java.lang.String txt)
txt
-
public java.lang.String getSubstringByChar(java.lang.String text, java.lang.String ch)
text
- from where to search and get final result.ch
- the character to search.
public java.lang.String firstCharUp(java.lang.String txt)
txt
-
public java.lang.String getName(java.lang.String path)
path
- file (absolute) path
getPathNoName(String path)
public java.lang.String getPathNoName(java.lang.String path)
path
-
getName(String path)
public java.lang.String getExt(java.lang.String filename)
filename
- with extension.
public java.lang.String replaceExt(java.lang.String filename, java.lang.String format)
filename
- without extension.format
- matching the extension.
public java.lang.String replaceExtBy(java.lang.String filename, java.lang.String newExt)
filename
- with extension.newExt
- of the new extension.
public java.lang.String getNameNoExt(java.lang.String pathtofile)
pathtofile
- with extension
public java.lang.String setExt(java.lang.String flname, java.lang.String format)
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.
FileFormatConverter.FASTA_F
,
FileFormatConverter.MASE_F
,
FileFormatConverter.PHYLIPI_F
,
FileFormatConverter.PHYLIPS_F
,
FileFormatConverter.CLUSTAL_F
,
OPTIONSFILE_F
,
R_OPTIONSFILE_F
public java.lang.String getFormatByExt(java.lang.String flname)
flname
- file name with extension.
FileFormatConverter.FASTA_F
,
FileFormatConverter.MASE_F
,
FileFormatConverter.PHYLIPI_F
,
FileFormatConverter.PHYLIPS_F
,
FileFormatConverter.CLUSTAL_F
public java.lang.String getNewGenFile(java.lang.String filePath, java.lang.String fileName)
filePath
- path of file (only directory(ies)).fileName
- name of file with extension.
public boolean pathExists(java.lang.String flpath)
flpath
- directory absolute path.
public java.io.BufferedReader getBR(java.lang.String filepath)
filepath
- absolute path for file.
public boolean renameFile(java.lang.String source, java.lang.String dest, boolean deletesrc)
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.
public java.lang.String readAAIndex1Properties(java.lang.String aaindex1file)
aaindex1file
- absolute path
public java.lang.String getAAindex1PropertyName()
readAAIndex1Properties(java.lang.String)
public boolean readOptionsFile(java.lang.String filepath)
filepath
- file to read from.
public void replaceBPFileParameterW(java.lang.String numProp)
numProp
- the total number of properties (NUM)public void writeOptionsToFile(java.lang.String filepath)
filepath
- file were to write.public java.lang.String[] readPhyMLStatFile(java.lang.String phystatFile)
phystatFile
- phyml stat file absolute path.
public java.lang.String[] readBppMLStatFile(java.lang.String bppstatFile)
bppstatFile
- phyml stat file absolute path.
public java.lang.String generateNewTmpRMainFile()
writeROptionsToFile(java.lang.String, java.lang.String)
public java.lang.String[] getRScriptVarNames()
public void initROptionsTable(java.lang.String[] keys)
keys
- public void setROption(java.lang.String key, java.lang.String option)
key
- that must exists in order to set option.option
- value associated.public java.lang.String getROption(java.lang.String key)
key
- identify which value.
public void readROptionsFile(java.lang.String r_optsfile)
r_optsfile
- r options absolute file path.initROptionsTable(java.lang.String[])
public java.lang.String buildROptionsToFile()
public java.lang.String writeROptionsToFile(java.lang.String optionsR, java.lang.String filepath)
optionsR
- options.filepath
- specified absolute file path to save in. If null used for execution; acts using temporary files.
generateNewTmpRMainFile()
public void removeRTmpFiles()
public java.lang.String getFileContent(java.io.InputStream file)
file
- input stream.
public boolean downloadFile(java.lang.String uurl, java.io.File tmpout)
uurl
- user url from where to download file.tmpout
- file where contents will be saved.
public boolean isProperAAi1File(java.lang.String filepath)
filepath
- AAindex1 file path.
public java.lang.String[] getPropNames()
public int getNumOfProp()
public int getPropIndexByValue(java.lang.String value)
value
- to search for.
public int getPropIndexByPath(java.lang.String path)
path
- to search for.
public java.lang.String getPropNameByIndex(int index)
index
- of property.
public java.lang.String getFilePathByValue(java.lang.String value)
value
- from file; which is the description ('D ' field).
public java.lang.String getAAindex1URL()
public void setAAindex1URL(java.lang.String url)
url
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |