|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprocope.tools.namemapping.ProteinManager
public class ProteinManager
This class contains static methods which perform the mapping of string
identifiers for proteins to internal integer IDs. Identical strings return
identical internal IDs. Case-sensitivity is controlled using
setCaseSensitivity(boolean)
.
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, boolean)
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.
Field Summary | |
---|---|
protected static boolean |
caseSensitive
Should protein identifiers be handled case-sensitive? This value can be changed using setCaseSensitivity(boolean) |
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,
boolean targetFirst)
Add a list of name mappings to the protein manager. |
static void |
clearAnnotations()
Deletes all protein annotations. |
static void |
clearNameMappings()
Removes all existing name mappings from the protein manager. |
static int |
getAnnotatedProteinCount()
Returns the number of proteins which have an annotation. |
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(String label)
Returns the internal protein ID for a given String protein label |
static String |
getLabel(int internalID)
Returns the protein label 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(InputStream instream)
Load protein annotations from a given stream. |
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, boolean targetFirst)
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 mappingstargetFirst
- true
: the first node of each edge (the source
of the directed edge) is the target protein identifier
where as the second node (the target of the directed
edge) is its synonym; false
: vice versa,
synonym comes first, then the targetpublic static void clearNameMappings()
public static Synonyms getSynonyms()
Synonyms
object currently used
Synonyms
object used in the protein managerpublic static int getInternalID(String label)
label
- protein label for which the internal ID will be returned
public static String getLabel(int internalID)
#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)
stream
- 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 loadProteinAnnotations(InputStream instream) throws IOException
instream
- stream 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
public static void clearAnnotations()
public static int getAnnotatedProteinCount()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |