|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttools.namemapping.ProteinManager
public class ProteinManager
This class contains static methods which perform the mapping of string identifiers for proteins to internal integer IDs. This works as follows:
ProteinLabel
.
The simplest protein label is just a String, the conversion of Strings
to protein labels is done automatically by the protein manager.ProteinLabel
. This library
delivers such a specific label with ProteinLabelOrganism
which
contains a string identifier associated with an organism.ProteinLabel
or same identifier and same organism for a
ProteinLabelOrganism
) the manager will always return the same
internal id.Quick start
If you quickly want internal IDs for string identifiers without
bothering about anything else, simple call getInternalID(String)
for each of your identifiers. Same identifiers will return the same internal
IDs.
Name mappings
Name mappings are useful if you are working with proteins which have
different synonyms or database identifiers. You simple provide the mappings
as a directed network (which you can read from a file) and the protein
manager will automatically map those names according to the edges in the
network. See also: addNameMappings(ProteinNetwork)
Regular expressions
If you are reading files where the needed identifiers are contained in
longer protein identification strings you can use regular expressions to
parse the information you need from the string. Use
setRegularExpression(String)
to parse all incoming identifiers
using the given expression and unsetRegularExpression()
to stop
using a regular expression.
ProteinLabel
,
ProteinLabelOrganism
Field Summary | |
---|---|
protected static boolean |
caseSensitive
Should protein identifiers be handled case-sensitive? |
Method Summary | |
---|---|
static Object |
addAnnotation(int internalID,
String key,
Object value)
Adds an annotation to the protein with a given internal ID. |
static void |
addAnnotations(int internalID,
Map<String,Object> newAnnotations)
Adds set of annotations to a protein with a given internal ID. |
static void |
addNameMappings(ProteinNetwork mappings)
Add a list of name mappings to the protein manager. |
static void |
clearNameMappings()
Removes all existing name mappings from the protein manager. |
static Object |
getAnnotation(int internalID,
String key)
Retrieves an annotation for a given protein. |
static Map<String,Object> |
getAnnotations(int internalID)
Retrieves all annotations for a given protein. |
static Set<Integer> |
getFilteredProteins(BooleanExpression expression)
Return the subset of proteins which match a given expression. |
static int |
getInternalID(ProteinLabel label)
Returns the internal protein ID for a given ProteinLabel |
static int |
getInternalID(String label)
Returns the internal ID for a given string identifier. |
static ProteinLabel |
getLabel(int internalID)
Returns the ProteinLabel associated with a given internal id. |
static int |
getProteinCount()
Returns the number of registered proteins. |
static Synonyms |
getSynonyms()
Return the Synonyms object currently used |
static void |
loadProteinAnnotations(String file)
Load protein annotations from a given file. |
static void |
main(String[] args)
|
static void |
saveProteinAnnotations(File file)
Saves protein annotations to a given file. |
static void |
saveProteinAnnotations(OutputStream stream)
Saves protein annotations to a given output stream. |
static void |
saveProteinAnnotations(String file)
Saves protein annotations to a given file. |
static void |
setCaseSensitivity(boolean sensitive)
Set if text identifiers should be case sensitive. |
static void |
setRegularExpression(String regex)
Use given regular expression to parse the actual identifier from the next incoming text identifiers ( see above ). |
static void |
unsetRegularExpression()
Do not use regular expression parsing for the following incoming text identifiers |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static boolean caseSensitive
setCaseSensitivity(boolean)
Method Detail |
---|
public static void addNameMappings(ProteinNetwork mappings)
A=>B
in the network
means that each occurence of the name A
will be translated to
{code B}. The name mappings will be added to the Synonyms
object of the protein manager.
mappings
- directed network containing name mappingspublic static void clearNameMappings()
public static Synonyms getSynonyms()
Synonyms
object currently used
Synonyms
object used in the protein managerpublic static int getInternalID(ProteinLabel label)
ProteinLabel
label
- protein label for which the internal ID will be returned
public static int getInternalID(String label)
ProteinLabel
object.
label
- protein label for which the internal ID will be returned
public static ProteinLabel getLabel(int internalID)
ProteinLabel
associated with a given internal id.
If there is no label for this ID it will return a new label with
the identifer #UNASSIGNED ID: [id]#
internalID
- internal ID for which the protein label will be returned
public static Object addAnnotation(int internalID, String key, Object value) throws ProCopeException
Integer
, Float
, String
or a List
.
Existing annotations with the same key will be overwritten
internalID
- internal ID of the protein for which an annotation is addedkey
- key of the annotationvalue
- value of the annotation
null
if this key is new
ProCopeException
- if the internal ID is not assignedpublic static void addAnnotations(int internalID, Map<String,Object> newAnnotations) throws ProCopeException
addAnnotation(int, String, Object)
.<
Existing annotations will be overwritten.
internalID
- internal ID of the protein for which the annotations
will be addednewAnnotations
- map of annotations to be added.
ProCopeException
- if the internal ID is not assignedpublic static Object getAnnotation(int internalID, String key) throws ProCopeException
internalID
- internal ID of the proteinkey
- key of the annotation
null
ProCopeException
- if the internal ID is not assignedpublic static Map<String,Object> getAnnotations(int internalID) throws ProCopeException
internalID
- internal ID of the protein
ProCopeException
- if the internal ID is not assignedpublic static int getProteinCount()
public static Set<Integer> getFilteredProteins(BooleanExpression expression)
BooleanExpression
expression
- expression to be evaluated
public static void setRegularExpression(String regex) throws PatternSyntaxException
see above
).
regex
- regular expression to be used
PatternSyntaxException
- If the expression's syntax is invalidpublic static void unsetRegularExpression()
public static void setCaseSensitivity(boolean sensitive)
true
, YPR173C and ypr173c will
return the same internal ID.
sensitive
- identifiers case-sensitive?public static void saveProteinAnnotations(String file) throws IOException
file
- output file
IOException
- if the file could not be writtenaddAnnotation(int, String, Object)
public static void saveProteinAnnotations(File file) throws IOException
file
- output file
IOException
- if the file could not be writtenaddAnnotation(int, String, Object)
public static void saveProteinAnnotations(OutputStream stream)
file
- output streamaddAnnotation(int, String, Object)
public static void loadProteinAnnotations(String file) throws IOException, ProCopeException
file
- file to load annotations from
IOException
- if the file could not be opend
ProCopeException
- if the file format is invalid or something else went wrongpublic static void main(String[] args) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |