root/plone4bio.base/trunk/src/plone4bio/base/README.txt

Revision 190, 4.5 KB (checked in by mauro, 12 months ago)

update docs

Line 
1==============
2plone4bio.base
3==============
4
5Overview
6--------
7
8The *plone4bio* package provides the possibility to add a new content
9type, called sequence, than can be either written by hand or imported
10from a FASTA file, and to apply to that sequence a program, called
11predictor, that gives a back a plot of predicted probabilites for the
12sequence to have a given property (the property that the predictor tries
13to determine).
14
15A predictor can try to assess if a protein sequence is trans-membrane,
16whether a signal peptide exists, and so on.
17
18The *plone4bio.base* is a package that defines a skeleton
19predictor: deriving from that it is possible to integrate any other
20application and visualize all the results together.  A predictor can be
21a pure Python program or another application wrapped to be usable by the
22interface defined in the *plone4bio.base* package.
23
24Creating a sequence
25-------------------
26
27Let us create some sequences.
28
29    >>> self.login()
30    >>> self.setRoles(('Manager',))
31    >>> self.portal.invokeFactory('SeqRecord', u'ferritin', title=u'Ferritin')
32    'ferritin'
33    >>> ferritin = getattr(self.portal, u'ferritin')
34    >>> ferritin.descritpion = u"Ferritin sequence"
35    >>> ferritin.sequence = u"CMSPDQWDKEAAQYDAHAQEFEKKSHRNNGTPEADQYRHMASQYQAMAQKLKAIANQLKKGSETCR"
36    >>> ferritin.alphabet="Bio.Alphabet.ProteinAlphabet"
37
38Now we can read some sequence properties:
39
40    >>> ferritin.seqrecord
41    SeqRecord(seq=Seq('CMSPDQWDKEAAQYDAHAQEFEKKSHRNNGTPEADQYRHMASQYQAMAQKLKAI...TCR', ProteinAlphabet()), id='ferritin', name=u'Ferritin', description='', dbxrefs=[])
42
43    >>> from Products.CMFCore.utils import getToolByName
44    >>> pred_tool = getToolByName(self.portal, 'plone4bio_predictors')
45
46Define a fake predictor:
47
48    >>> import copy
49    >>> from plone4bio.base.interfaces import IPredictor
50    >>> from zope.interface import implements
51    >>> from Bio.SeqFeature import FeatureLocation, SeqFeature
52    >>> class FakePredictor:
53    ...     implements(IPredictor)
54    ...     def name(self):
55    ...         return self.__class__.__name__
56    ...
57    ...     def run(self, seqr, **kwargs):
58    ...         seqr = copy.deepcopy(seqr)
59    ...         seqr.features.append(SeqFeature(location=FeatureLocation(1,len(seqr.seq)), type="fake"))
60    ...         return seqr
61    ...
62
63Register fake predictor:
64
65    >>> pred_tool.registerPredictor(FakePredictor())
66    >>> pred_tool.listPredictors()
67    [<Predictor at /plone/plone4bio_predictors/FakePredictor>]
68
69Run fake predictor over ferritin seqrecord:
70
71    >>> seqr_ann = pred_tool('FakePredictor', ferritin.seqrecord, store=False)
72    >>> seqr_ann
73    SeqRecord(seq=Seq('CMSPDQWDKEAAQYDAHAQEFEKKSHRNNGTPEADQYRHMASQYQAMAQKLKAI...
74    >>> len(seqr_ann.features)
75    1
76    >>> print seqr_ann.features[0]
77    type: fake
78    location: [1:66]
79    strand: None
80    qualifiers:
81
82Original seqrecord must be untouched:
83
84    >>> len(ferritin.seqrecord.features)
85    0
86
87Now run the predictor over Plone4Bio's SeqRecord wrapper:
88
89    >>> seqr_ann = pred_tool('FakePredictor', ferritin, store=False)
90    >>> seqr_ann
91    <SeqRecord at ferritin>
92    >>> seqr_ann.seqrecord
93    SeqRecord(seq=Seq('CMSPDQWDKEAAQYDAHAQEFEKKSHRNNGTPEADQYRHMASQYQAMAQKLKAI...
94    >>> len(seqr_ann.seqrecord.features)
95    1
96    >>> len(ferritin.seqrecord.features)
97    0
98    >>> pred_tool('FakePredictor', ferritin, store=True)
99    <SeqRecord at /plone/ferritin>
100    >>> len(ferritin.seqrecord.features)
101    1
102
103...
104
105Developer Notes
106===============
107The *plone4bio* plone products are mainly developed on Debian Stable, so
108they are mainly tested in that environment. Usually there should be no
109problem in installing the products in other Zope/Plone environments.
110
111This product is produced independently from the product Plone, and carries no
112guarantee from the Plone Foundation about quality, suitability or anything
113else. The supplier of this product assumes all responsibility for it.
114
115Getting the source code
116-----------------------
117
118The source code is maintained in the Plone4Bio Subversion
119repository. To check out the trunk: ::
120
121  $ svn co http://plone4bio.org/svn/plone4bio.base/trunk/
122
123You can also browse the code online at
124`http://plone4bio.org/trac/browser/plone4bio.base/trunk
125<http://plone4bio.org/trac/browser/plone4bio.base/trunk>`_.
126
127When using setuptools or zc.buildout you can use the following
128URL to retrieve the latest development code as Python egg: ::
129
130  $ http://plone4bio.org/svn/plone4bio.base/trunk/#egg=plone4bio.base
131
132
133Bug tracker
134===========
135For bug reports, suggestions or questions please use the
136Launchpad bug tracker at
137`http://plone4bio.org
138<http://plone4bio.org>`_.
139
Note: See TracBrowser for help on using the browser.