| 1 | ============== |
|---|
| 2 | plone4bio.base |
|---|
| 3 | ============== |
|---|
| 4 | |
|---|
| 5 | Overview |
|---|
| 6 | -------- |
|---|
| 7 | |
|---|
| 8 | The *plone4bio* package provides the possibility to add a new content |
|---|
| 9 | type, called sequence, than can be either written by hand or imported |
|---|
| 10 | from a FASTA file, and to apply to that sequence a program, called |
|---|
| 11 | predictor, that gives a back a plot of predicted probabilites for the |
|---|
| 12 | sequence to have a given property (the property that the predictor tries |
|---|
| 13 | to determine). |
|---|
| 14 | |
|---|
| 15 | A predictor can try to assess if a protein sequence is trans-membrane, |
|---|
| 16 | whether a signal peptide exists, and so on. |
|---|
| 17 | |
|---|
| 18 | The *plone4bio.base* is a package that defines a skeleton |
|---|
| 19 | predictor: deriving from that it is possible to integrate any other |
|---|
| 20 | application and visualize all the results together. A predictor can be |
|---|
| 21 | a pure Python program or another application wrapped to be usable by the |
|---|
| 22 | interface defined in the *plone4bio.base* package. |
|---|
| 23 | |
|---|
| 24 | Creating a sequence |
|---|
| 25 | ------------------- |
|---|
| 26 | |
|---|
| 27 | Let 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 | |
|---|
| 38 | Now 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 | |
|---|
| 46 | Define 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 | |
|---|
| 63 | Register fake predictor: |
|---|
| 64 | |
|---|
| 65 | >>> pred_tool.registerPredictor(FakePredictor()) |
|---|
| 66 | >>> pred_tool.listPredictors() |
|---|
| 67 | [<Predictor at /plone/plone4bio_predictors/FakePredictor>] |
|---|
| 68 | |
|---|
| 69 | Run 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 | |
|---|
| 82 | Original seqrecord must be untouched: |
|---|
| 83 | |
|---|
| 84 | >>> len(ferritin.seqrecord.features) |
|---|
| 85 | 0 |
|---|
| 86 | |
|---|
| 87 | Now 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 | |
|---|
| 105 | Developer Notes |
|---|
| 106 | =============== |
|---|
| 107 | The *plone4bio* plone products are mainly developed on Debian Stable, so |
|---|
| 108 | they are mainly tested in that environment. Usually there should be no |
|---|
| 109 | problem in installing the products in other Zope/Plone environments. |
|---|
| 110 | |
|---|
| 111 | This product is produced independently from the product Plone, and carries no |
|---|
| 112 | guarantee from the Plone Foundation about quality, suitability or anything |
|---|
| 113 | else. The supplier of this product assumes all responsibility for it. |
|---|
| 114 | |
|---|
| 115 | Getting the source code |
|---|
| 116 | ----------------------- |
|---|
| 117 | |
|---|
| 118 | The source code is maintained in the Plone4Bio Subversion |
|---|
| 119 | repository. To check out the trunk: :: |
|---|
| 120 | |
|---|
| 121 | $ svn co http://plone4bio.org/svn/plone4bio.base/trunk/ |
|---|
| 122 | |
|---|
| 123 | You 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 | |
|---|
| 127 | When using setuptools or zc.buildout you can use the following |
|---|
| 128 | URL to retrieve the latest development code as Python egg: :: |
|---|
| 129 | |
|---|
| 130 | $ http://plone4bio.org/svn/plone4bio.base/trunk/#egg=plone4bio.base |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | Bug tracker |
|---|
| 134 | =========== |
|---|
| 135 | For bug reports, suggestions or questions please use the |
|---|
| 136 | Launchpad bug tracker at |
|---|
| 137 | `http://plone4bio.org |
|---|
| 138 | <http://plone4bio.org>`_. |
|---|
| 139 | |
|---|