public class MAGETABUtils extends Object
| Constructor and Description | 
|---|
MAGETABUtils()  | 
| Modifier and Type | Method and Description | 
|---|---|
static String | 
compensateForEscapedNewlines(String firstLine,
                            String secondLine)
Deprecated.  
 | 
static String | 
digestHeader(String header)
Remove any unescaped or unparenthesised whitespace, and convert to lower case for a single header field 
 | 
static String[] | 
digestHeaders(String[] header)
Remove any unescaped or unparenthesised whitespace, and convert to lower case for a row of headers 
 | 
static boolean | 
endsWithEscapedNewline(String line)
Deprecated.  
 | 
static String | 
escapeCell(String cell)
Performs all necessary escaping for cell values using the following rules:
  - all TAB characters replaced with spaces
  - cells containing CR and/or LF characters are quoted using double-quotes
  - existing quoting is preserved
  - all double-quote characters inside cell will be escaped by pre-pending backslash
  - existing escaping is preserved 
 | 
static <T> T[] | 
extractRange(T[] array,
            int startIndex)
Extract a subset of an array from a larger array. 
 | 
static <T> T[] | 
extractRange(T[] array,
            int startIndex,
            int endIndex)
Extract a subset of an array from a larger array. 
 | 
static String | 
extractSubtype(String header)
Extract the subtype given in the header. 
 | 
static String | 
extractType(String header)
Extract the type given in the header. 
 | 
static String[][] | 
insertColumn(String[][] data,
            String header,
            int insertBefore)  | 
static boolean | 
isAnchoredAttribute(String parentHeader,
                   String attributeHeader)
Determines whether the supplied attribute header is anchored to the parent header. 
 | 
static boolean | 
isMergedTabDelimitedInputStream(InputStream in,
                               String encoding,
                               String... sectionTags)
If possible, checks whether the supplied input stream reads from a merged MAGE-TAB file. 
 | 
static File | 
locateIDF(File dir)
Given a directory that represents a MAGE-TAB document, locate the IDF file it contains 
 | 
static File | 
locateSDRF(File dir)
Given a directory that represents a MAGE-TAB document, locate the SDRF file it contains 
 | 
static String[][] | 
readMergedTabDelimitedInputStream(InputStream in,
                                 String encoding,
                                 boolean stripEscaping,
                                 boolean trimWhitespace,
                                 String... sectionTags)
Deprecated.  
 | 
static String[][] | 
readMergedTabDelimitedInputStream(InputStream in,
                                 String encoding,
                                 boolean stripEscaping,
                                 String... sectionTags)
Deprecated.  
 | 
static String[][] | 
readTabDelimitedInputStream(InputStream in,
                           String encoding,
                           boolean stripEscaping)
Deprecated.  
 | 
static String[][] | 
readTabDelimitedInputStream(InputStream in,
                           String encoding,
                           boolean stripEscaping,
                           boolean trimWhitespace)
Deprecated.  
 | 
static String[] | 
removeEscaping(String line)
Deprecated.  
 | 
static String[] | 
removeEscaping(String[] cells)
Deprecated.  
 | 
static String[] | 
removeEscaping(String[] cells,
              boolean useStrict)
Deprecated.  
 | 
static String[] | 
removeEscaping(String line,
              boolean useStrict)
Deprecated.  
 | 
static String[] | 
removeTrailingEmptyCells(String[] row)
Deprecated.  
 | 
static String[] | 
removeWhitespace(String[] cells)
Deprecated.  
 | 
static Map<String,String> | 
resolveExperimentFactorTypes(MAGETABInvestigation investigation,
                            HybridizationNode hybNode)
Resolves all the factor value types (the typing information in square brackets - so "foo" in Factor Value[foo])
 in the provided hybridization node and maps them to the actual experiment factor type declared in the IDF. 
 | 
static URL | 
resolveRelativeLocation(URL currentLocation,
                       String relativeFileName)
Convenience method for obtaining the URL for a file given only a relative path and the URL of the document the
 relative path is declared in. 
 | 
static String[] | 
splitLine(String line)
Deprecated.  
 | 
static String[] | 
splitLine(String line,
         boolean ignoreEscaping)
Deprecated.  
 | 
static String[] | 
splitLine(String line,
         boolean ignoreEscaping,
         boolean trimWhitespace)
Deprecated.  
 | 
@Deprecated public static String[][] readTabDelimitedInputStream(InputStream in, String encoding, boolean stripEscaping, boolean trimWhitespace) throws IOException
in - the input stream to read fromencoding - the encoding type of the input streamstripEscaping - whether to remove any quotes used to escape cells before returning the resulttrimWhitespace - whether to remove whitespace from lines before splitting into cellsIOException - if the stream could not be read@Deprecated public static String[][] readTabDelimitedInputStream(InputStream in, String encoding, boolean stripEscaping) throws IOException
in - the input stream to read fromencoding - the encoding type of the input streamstripEscaping - whether to remove any quotes used to escape cells before returning the resultIOException - if the stream could not be read@Deprecated public static String[][] readMergedTabDelimitedInputStream(InputStream in, String encoding, boolean stripEscaping, String... sectionTags) throws IOException
readTabDelimitedInputStream(java.io.InputStream, String,
 boolean) in that it is capable of reading a file divided into sections by tags that indicate the split.  In the
 case of some MAGE-TAB files, this is denoted by [IDF] and [SDRF] tags.  Such tags
 should be passed as the sectionTags parameter.  This method skips the first section tag if it occurs before other
 content, and then breaks at any subsequent section markers it encounters.in - the input stream to read fromencoding - the encoding type of the input streamstripEscaping - whether to remove any quotes used to escape cells before returning the resultsectionTags - the labels that delineate sections in this stream (one per line)IOException - if the stream could not be read@Deprecated public static String[][] readMergedTabDelimitedInputStream(InputStream in, String encoding, boolean stripEscaping, boolean trimWhitespace, String... sectionTags) throws IOException
readTabDelimitedInputStream(java.io.InputStream, String,
 boolean) in that it is capable of reading a file divided into sections by tags that indicate the split.  In the
 case of some MAGE-TAB files, this is denoted by [IDF] and [SDRF] tags.  Such tags
 should be passed as the sectionTags parameter.  This method skips the first section tag if it occurs before other
 content, and then breaks at any subsequent section markers it encounters.in - the input stream to read fromencoding - the encoding type of the input streamstripEscaping - whether to remove any quotes used to escape cells before returning the resulttrimWhitespace - whether to remove whitespace from lines before splitting into cellssectionTags - the labels that delineate sections in this stream (one per line)IOException - if the stream could not be readpublic static boolean isMergedTabDelimitedInputStream(InputStream in, String encoding, String... sectionTags) throws IOException
in - the input stream to testencoding - the encoding type of the input streamsectionTags - the tags thatIOException - if the underlying stream does not support the mark() operationpublic static String[][] insertColumn(String[][] data, String header, int insertBefore)
@Deprecated public static String[] removeTrailingEmptyCells(String[] row)
row - the cells to remove trailing whitespace from@Deprecated public static boolean endsWithEscapedNewline(String line)
line - the line to inspect@Deprecated public static String compensateForEscapedNewlines(String firstLine, String secondLine)
endsWithEscapedNewline(String)) and then concatenates the two strings.  Note that it will first check whether
 the first line does indeed end in an escaped newline, and if not it will throw an exception. However, there are
 situations when this will fail. When parsing a single line, whether this line ends in an escaped newline
 character is judged by checking each tab-delimited cell and if there are cells that start with a quote and do NOT
 end in a quote before the end of the line, this line is assumed to end in an escaped newline character.  If there
 are consecutive lines ending in this way, however, every second line will look like this yet will NOT end with an
 escaped newline.  Therefore, care must be taken to remove all escaped newline characters in order, concatenating
 each string as you parse, before calling this method.firstLine - the first line, i.e. the one ending with an escaped newline charactersecondLine - the second line, i.e. the one that is a logical continuation of the first@Deprecated public static String[] splitLine(String line)
splitLine(line, false); (see splitLine(String, boolean)).line - the line to split@Deprecated public static String[] splitLine(String line, boolean ignoreEscaping)
splitLine(line, ignoreEscaping, true); (see splitLine(String, boolean, boolean)).line - the line to splitignoreEscaping - whether to ignore escaped tab and newline characters or whether to handle them according to
                       the MAGE-TAB spec.@Deprecated public static String[] splitLine(String line, boolean ignoreEscaping, boolean trimWhitespace)
line - the line to splitignoreEscaping - whether to ignore escaped tab and newline characters or whether to handle them according to
                       the MAGE-TAB spec.trimWhitespace - whether to act in 'strict' mode, preserving any leading and trailing whitespace characters,
                       or whether to automatically remove them@Deprecated public static String[] removeEscaping(String line)
splitLine(line, false); followed by removeEscaping(cells); on the result.line - the line containing cells to remove escaping from@Deprecated public static String[] removeEscaping(String line, boolean useStrict)
splitLine(line); followed by removeEscaping(cells); on the result.line - the line containing cells to remove escaping fromuseStrict - whether to strictly remove all quotation marks from this cell, or whether to consider only those
                  at the beginning and end of each cell.@Deprecated public static String[] removeEscaping(String[] cells)
removeEscaping(cells, false);cells - the cells to remove escaping from@Deprecated public static String[] removeEscaping(String[] cells, boolean useStrict)
endsWithEscapedNewline(String) and compensateForEscapedNewlines(String, String) methods first.
 
 In 'relaxed' mode, this method removes quotations ONLY when present at the beginning and end of a cell. This form
 is different from strict checking in that it does not use regular expressions to check for quoted substrings -
 rather, it just checks the first and last character of each cell for quotations. Relaxed mode will work with
 lines that end in an escaped newline character or may not pass regular expression checks.
 
 Generally, MAGE-TAB convention is to only quote around cells (and not within cells) to imply escaping, so relaxed
 mode is almost always the preferred option.  For thorough sensitivity use the strict form,cells - the logical cells on a line of MAGE-TAB that may contain segments escaped with quotation marksuseStrict - whether to use the strict definition of escaping from the MAGE-TAB spec, or whether to consider
                  quotations at the beginning and end of cells only.@Deprecated public static String[] removeWhitespace(String[] cells)
cells - the cells to trim leading and trailing whitespace frompublic static String digestHeader(String header)
header - the header to digestpublic static String[] digestHeaders(String[] header)
header - the header to digestpublic static String extractType(String header)
header - the header to readpublic static String extractSubtype(String header)
header - the header to readpublic static URL resolveRelativeLocation(URL currentLocation, String relativeFileName) throws IOException
currentLocation - the location of the declaring documentrelativeFileName - the path to the declared file relative to the declaring documentIOException - if the path declared does not declare a valid pathpublic static File locateIDF(File dir)
dir - the directory containing all the MAGE-TAB documentspublic static File locateSDRF(File dir)
dir - the directory containing all the MAGE-TAB documentspublic static <T> T[] extractRange(T[] array,
                   int startIndex,
                   int endIndex)
startIndex to endIndex
 inclusive will be extracted and returned as a new array.  The type of the array will be preserved.  The start and
 index values are zero indexed and are inclusive: in other words, the maximum range that can be extracted is from
 0 to array.length-1.  If the endIndex value is greater than this, the result would be the same as using the
 extractRange(Object[], int) form of this method - it will extract to the end and no further.T - the type of the arrayarray - the array to extract a subset fromstartIndex - the first element to extract, zero indexed, inclusiveendIndex - the last element to extract, zero indexed, inclusive - if this is greater than the length of
                   the array this will extract to the end of the arraypublic static <T> T[] extractRange(T[] array,
                   int startIndex)
startIndex to the end of the array,
 inclusive will be extracted and returned as a new array.  The type of the array will be preserved.T - the type of the arrayarray - the array to extract a subset fromstartIndex - the first element to extract, zero indexed, inclusivepublic static boolean isAnchoredAttribute(String parentHeader, String attributeHeader)
parentHeader - the parent attribute the new attribute may be anchored toattributeHeader - the new attribute being testedpublic static Map<String,String> resolveExperimentFactorTypes(MAGETABInvestigation investigation, HybridizationNode hybNode)
investigation - the MAGETAB investigation this hybNode is present inhybNode - the hybNode to resolve factor types forpublic static String escapeCell(String cell)
cell - input cell text valueCopyright © 2014. All rights reserved.