Package uk.ac.ebi.pride.jmztab2.model
Class MZTabUtils
- java.lang.Object
-
- uk.ac.ebi.pride.jmztab2.model.MZTabUtils
-
public class MZTabUtils extends Object
Provide a couple of functions for translating, parsing and printing formatted strings defined in the mzTab specification.- Since:
- 30/01/13
- Author:
- qingwei, nilshoffmann
-
-
Constructor Summary
Constructors Constructor Description MZTabUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Double
parseDouble(String target)
NOTICE: If ratios are included and the denominator is zero, the "INF" value MUST be used.static List<Double>
parseDoubleList(String target)
parseDoubleList.static String
parseEmail(String target)
Parse the target string, and check is obey the email format or not.static List<String>
parseGOTermList(String target)
A '|' delimited list of GO accessionsstatic IndexedElement
parseIndexedElement(String target, MetadataElement element)
parse the target into aIndexedElement
object.static Integer
parseInteger(String target)
parseInteger.static List<Integer>
parseIntegerList(String target)
parseIntegerList.static Long
parseLong(String target)
parseLong.static String
parseMzTabVersion(String target)
Parse the target string, and check it follows the mzTab Version format.static Parameter
parseParam(String target)
Parameters are always reported as [CV label, accession, name, value].static List<Parameter>
parseParamList(String target)
A list of '|' separated parametersstatic Publication
parsePublicationItems(Publication publication, int lineNumber, String target)
A publication on this unit.static List<IndexedElement>
parseRefList(String target, MetadataElement element)
Parse the target into aIndexedElement
list.static List<SpectraRef>
parseSpectraRefList(MZTabParserContext context, Metadata metadata, String target)
Parse aSpectraRef
list.static List<String>
parseStringList(char splitChar, String target)
Multiple identifiers MUST be separated by splitChar.static URI
parseURI(String target)
parseURI.static String
printDouble(Double value)
If ratios are included and the denominator is zero, the "INF" value MUST be used.static String
removeDoubleQuotes(String value)
If there exists reserved characters in value, like comma, the string need to be escape.static String
translateCommaToTab(String target)
locate param label [label, accession, name, value], translate ',' to '\t'static String
translateLastToTab(String target)
translateLastToTab.static String
translateMinusInCVtoUnicode(String target)
translateMinusInCVtoUnicode.static String
translateMinusToTab(String target)
translateMinusToTab.static String
translateMinusToUnicode(String target)
Solve the conflict about minus char between modification position and CHEMMOD charge.static String
translateTabToComma(String target)
solve the conflict about comma char which used in split modification and split cv param components.static String
translateTabToMinus(String target)
solve the conflict about comma char which used in split modification and split cv param components.static String
translateUnicodeCVTermMinus(String target)
translateUnicodeCVTermMinus.static String
translateUnicodeToMinus(String target)
Solve the conflict about minus char between modification position and CHEMMOD charge.
-
-
-
Constructor Detail
-
MZTabUtils
public MZTabUtils()
-
-
Method Detail
-
printDouble
public static String printDouble(Double value)
If ratios are included and the denominator is zero, the "INF" value MUST be used. If the result leads to calculation errors (for example 0/0), this MUST be reported as "not a number" ("NaN").- Parameters:
value
- aDouble
object.- Returns:
- a
String
object. - See Also:
parseDouble(String)
-
parseEmail
public static String parseEmail(String target)
Parse the target string, and check is obey the email format or not. If not, return null.
-
parseMzTabVersion
public static String parseMzTabVersion(String target)
Parse the target string, and check it follows the mzTab Version format. If not, return null.
-
parseParam
public static Parameter parseParam(String target)
Parameters are always reported as [CV label, accession, name, value]. Any field that is not available MUST be left empty. If the name or value of param contains comma, quotes MUST be added to avoid problems. Nested double quotes are not supported. Notice: name cell never set null.
-
parseStringList
public static List<String> parseStringList(char splitChar, String target)
Multiple identifiers MUST be separated by splitChar.
-
parseIndexedElement
public static IndexedElement parseIndexedElement(String target, MetadataElement element)
parse the target into aIndexedElement
object.- Parameters:
target
- aString
object.element
- aMetadataElement
object.- Returns:
- a
IndexedElement
object.
-
parseRefList
public static List<IndexedElement> parseRefList(String target, MetadataElement element)
Parse the target into aIndexedElement
list. target is a '|' separated list of entries.- Parameters:
target
- aString
object.element
- aMetadataElement
object.- Returns:
- a
List
object.
-
parseParamList
public static List<Parameter> parseParamList(String target)
A list of '|' separated parameters
-
parseGOTermList
public static List<String> parseGOTermList(String target)
A '|' delimited list of GO accessions
-
parseInteger
public static Integer parseInteger(String target)
parseInteger.
-
parseDouble
public static Double parseDouble(String target)
NOTICE: If ratios are included and the denominator is zero, the "INF" value MUST be used. If the result leads to calculation errors (for example 0/0), this MUST be reported as "not a number" ("NaN").
-
parseDoubleList
public static List<Double> parseDoubleList(String target)
parseDoubleList.
-
parseIntegerList
public static List<Integer> parseIntegerList(String target)
parseIntegerList.
-
parsePublicationItems
public static Publication parsePublicationItems(Publication publication, int lineNumber, String target) throws MZTabException
A publication on this unit. PubMed ids must be prefixed by "pubmed:", DOIs by "doi:". Multiple identifiers MUST be separated by "|".- Parameters:
publication
- aPublication
object.lineNumber
- the line number while parsing.target
- aString
object.- Returns:
- a
Publication
object. - Throws:
MZTabException
- in case of parsing or formatting issues of the publication string.
-
parseSpectraRefList
public static List<SpectraRef> parseSpectraRefList(MZTabParserContext context, Metadata metadata, String target)
Parse aSpectraRef
list.- Parameters:
context
- aMZTabParserContext
object.metadata
- aMetadata
object.target
- aString
object.- Returns:
- a
List
object.
-
translateMinusToUnicode
public static String translateMinusToUnicode(String target)
Solve the conflict about minus char between modification position and CHEMMOD charge. For example: 13-CHEMMOD:-159
-
translateMinusInCVtoUnicode
public static String translateMinusInCVtoUnicode(String target)
translateMinusInCVtoUnicode.
-
translateUnicodeCVTermMinus
public static String translateUnicodeCVTermMinus(String target)
translateUnicodeCVTermMinus.
-
translateUnicodeToMinus
public static String translateUnicodeToMinus(String target)
Solve the conflict about minus char between modification position and CHEMMOD charge. For example: 13-CHEMMOD:-159
-
translateCommaToTab
public static String translateCommaToTab(String target)
locate param label [label, accession, name, value], translate ',' to '\t'
-
translateTabToComma
public static String translateTabToComma(String target)
solve the conflict about comma char which used in split modification and split cv param components.
-
translateMinusToTab
public static String translateMinusToTab(String target)
translateMinusToTab.
-
translateLastToTab
public static String translateLastToTab(String target)
translateLastToTab.
-
translateTabToMinus
public static String translateTabToMinus(String target)
solve the conflict about comma char which used in split modification and split cv param components.
-
removeDoubleQuotes
public static String removeDoubleQuotes(String value)
If there exists reserved characters in value, like comma, the string need to be escape. However the escaping char is not store because it will be write back in the writer. Nested double quotes are not supported.
-
-