Changeset 171

Show
Ignore:
Timestamp:
10/03/10 16:58:48 (20 months ago)
Author:
mauro
Message:

prepare 1.1.0rc1

Location:
plone4bio.base/trunk
Files:
18 added
1 removed
38 modified

Legend:

Unmodified
Added
Removed
  • plone4bio.base/trunk/bootstrap.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/docs/CHANGES.txt

    r149 r171  
    33====================== 
    44 
    5 plone4bio.base 1.1.0 (unreleased) 
     5plone4bio.base 1.1.0rc1 (2010-10-03) 
    66================================= 
    77 
     
    1111* works with Plone 4.x 
    1212 
    13 * use plone4bio.graphics instead BioPerl's stuff 
     13* experimental support for biograpy (http://github.com/apierleoni/BioGraPy) 
     14 
     15* plone4bio.SeqRecordViewletManager added 
     16 
     17* manage dbxref patterns via controlpanel and genericsetup 
     18 
     19* experimental support for genbank upload 
    1420 
    1521plone4bio.base 1.0.2 (2010-06-03) 
  • plone4bio.base/trunk/setup.py

    • Property svn:keywords set to Date Revision Author Id
    r161 r171  
    22import os 
    33 
    4 version = '1.1.0' 
     4version = '1.1.0rc1' 
    55 
    66setup(name='plone4bio.base', 
  • plone4bio.base/trunk/src/plone4bio/__init__.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/Extensions/Install.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/__init__.py

    • Property svn:keywords set to Date Revision Author Id
    r78 r171  
     1import logging 
     2logger = logging.getLogger("plone4bio.base") 
     3logger.debug('Start initialization of product.') 
     4 
     5from Products.CMFCore import utils as cmfutils 
     6 
     7from Products.CMFCore import DirectoryView 
     8from Products.Archetypes.atapi import process_types 
     9from Products.Archetypes import listTypes 
     10 
     11from config import PROJECTNAME 
     12from config import DEFAULT_ADD_CONTENT_PERMISSION 
     13from config import ADD_CONTENT_PERMISSIONS 
     14from config import product_globals 
     15 
    116from zope.i18nmessageid import MessageFactory 
    217Plone4BioMessageFactory = MessageFactory('plone4bio') 
     18 
    319 
    420class Plone4BioException(Exception): 
     
    723def initialize(context): 
    824    """Intializer called when used as a Zope 2 product.""" 
     25    # imports packages and types for registration 
     26    import interfaces 
     27    import content 
     28 
     29    # Initialize portal content 
     30    all_content_types, all_constructors, all_ftis = process_types( 
     31        listTypes(PROJECTNAME), 
     32        PROJECTNAME) 
     33 
     34    cmfutils.ContentInit( 
     35        PROJECTNAME + ' Content', 
     36        content_types=all_content_types, 
     37        permission=DEFAULT_ADD_CONTENT_PERMISSION, 
     38        extra_constructors=all_constructors, 
     39        fti=all_ftis, 
     40        ).initialize(context) 
     41 
     42    # Give it some extra permissions to control them on a per class limit 
     43    for i in range(0, len(all_content_types)): 
     44        klassname = all_content_types[i].__name__ 
     45        if not klassname in ADD_CONTENT_PERMISSIONS: 
     46            continue 
     47 
     48        context.registerClass(meta_type=all_ftis[i]['meta_type'], 
     49                              constructors=(all_constructors[i],), 
     50                              permission=ADD_CONTENT_PERMISSIONS[klassname]) 
  • plone4bio.base/trunk/src/plone4bio/base/atct.py

    • Property svn:keywords set to Date Revision Author Id
    r152 r171  
     1# -*- coding: utf-8 -*- 
     2# 
     3# File: atct.py 
     4# 
     5# Copyright (c) 2010 by Mauro Amico (Biodec Srl) 
     6# 
     7# GNU General Public License (GPL) 
     8# 
     9# This program is free software; you can redistribute it and/or 
     10# modify it under the terms of the GNU General Public License 
     11# as published by the Free Software Foundation; either version 2 
     12# of the License, or (at your option) any later version. 
     13# 
     14# This program is distributed in the hope that it will be useful, 
     15# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     17# GNU General Public License for more details. 
     18# 
     19# You should have received a copy of the GNU General Public License 
     20# along with this program; if not, write to the Free Software 
     21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
     22# 02110-1301, USA. 
     23# 
     24# @version $Revision$: 
     25# @author  $Author$: 
     26# @date    $Date$: 
     27 
     28__author__ = '''Mauro Amico <mauro@biodec.com>''' 
     29__docformat__ = 'plaintext' 
     30 
    131from zope.interface import implements 
    2 from zope.component import adapts 
    3 from zope.filerepresentation.interfaces import IFileFactory 
    4 from plone4bio.base.interfaces import ISeqRecordContainer 
     32from Bio import SeqIO 
     33from plone4bio.base.interfaces import ISeqRecordUploader 
    534 
    6 # TODO 
     35 
    736class UploadingFileFactory(object): 
    8     implements(IFileFactory) 
    9     adapts(ISeqRecordContainer) 
     37    implements(ISeqRecordUploader) 
    1038 
    11     DEFAULT_TYPE = 'GFF File' 
     39    DEFAULT_TYPE = 'genbank' 
    1240 
    1341    def __init__(self, context): 
    1442        self.context = context 
    1543 
    16     def __call__(self, name, content_type, data): 
    17         # import pdb; pdb.set_trace() 
    18         pass 
    19  
    20     def loadData(self, *args, **kwargs): 
    21         # import pdb; pdb.set_trace() 
    22         pass 
    23  
     44    def loadData(self, data, data_type=DEFAULT_TYPE): 
     45        if data_type.lower() == 'genbank': 
     46            for seqr in SeqIO.parse(data, "genbank"): 
     47                newid = self.context.invokeFactory('SeqRecord', seqr.id, title=seqr.name) 
     48                obj = getattr(self.context, newid) 
     49                obj.sequence = seqr.seq.tostring() 
     50                obj.alphabet = str(seqr.seq.alphabet.__class__) 
     51                obj.features = seqr.features 
     52                obj.annotations = seqr.annotations 
     53        else: 
     54            raise 
  • plone4bio.base/trunk/src/plone4bio/base/browser/__init__.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/browser/configure.zcml

    r149 r171  
    22           xmlns:browser="http://namespaces.zope.org/browser"> 
    33 
    4 <!-- 
    5         <include package="plone4bio" file="permissions.zcml" /> 
    6 --> 
    7  
    8 <!-- new --> 
    9  
     4    <include package=".viewlets" /> 
     5     
    106    <browser:page 
    117                for="..interfaces.ISeqRecord" 
     
    3935    <browser:page 
    4036                for="..interfaces.ISeqRecord" 
    41                 name="edit" 
    42                 class=".seqrecord.SeqRecordEditForm" 
    43                 permission="cmf.ModifyPortalContent" 
    44                 /> 
    45  
    46     <browser:page 
    47                 for="..interfaces.ISeqRecord" 
    4837                name="predictors" 
    4938                class=".seqrecord.SeqRecordPredictors" 
     
    6150                /> 
    6251 
    63         <!--  TODO:adapter --> 
    6452    <browser:page 
    6553                for="..interfaces.ISeqRecord" 
    66                 name="gbk" 
    67                 class=".seqrecord.SeqRecord2Genbank" 
     54            name="gbk" 
     55                class=".genbank.SeqRecord2Genbank" 
    6856                permission="zope2.View" 
    6957                /> 
    7058 
    71         <!--  TODO:adapter --> 
    7259     <browser:page 
    7360                for="..interfaces.ISeqRecord" 
    7461            name="fasta" 
    75                 class=".seqrecord.SeqRecord2Fasta" 
     62                class=".fasta.SeqRecord2Fasta" 
    7663                permission="zope2.View" 
    7764                /> 
     
    8370        class=".container.LoadForm" 
    8471        permission="cmf.ModifyPortalContent" 
    85         /> 
    86  
    87      <browser:page 
    88         for="zope.app.container.interfaces.IAdding" 
    89         name="plone4bio.base.SeqRecord" 
    90         class=".seqrecord.SeqRecordAddForm" 
    91         permission="cmf.AddPortalContent" 
    9272        /> 
    9373 
     
    138118      /> 
    139119       
     120    <browser:resource 
     121      name="plone4bio_icon.png" 
     122      file="images/plone4bio_icon.png" 
     123      permission="zope2.View" 
     124      /> 
     125 
    140126</configure> 
  • plone4bio.base/trunk/src/plone4bio/base/browser/container.py

    • Property svn:keywords set to Date Revision Author Id
    r45 r171  
     1# -*- coding: utf-8 -*- 
     2# 
     3# File: container.py 
     4# 
     5# Copyright (c) 2010 by Mauro Amico (Biodec Srl) 
     6# 
     7# GNU General Public License (GPL) 
     8# 
     9# This program is free software; you can redistribute it and/or 
     10# modify it under the terms of the GNU General Public License 
     11# as published by the Free Software Foundation; either version 2 
     12# of the License, or (at your option) any later version. 
     13# 
     14# This program is distributed in the hope that it will be useful, 
     15# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     17# GNU General Public License for more details. 
     18# 
     19# You should have received a copy of the GNU General Public License 
     20# along with this program; if not, write to the Free Software 
     21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
     22# 02110-1301, USA. 
     23# 
     24# @version $Revision$: 
     25# @author  $Author$: 
     26# @date    $Date$: 
     27 
     28__author__ = '''Mauro Amico <mauro@biodec.com>''' 
     29__docformat__ = 'plaintext' 
     30 
    131 
    232from datetime import datetime 
     
    737from plone4bio.base import Plone4BioMessageFactory as _ 
    838from plone4bio.base.interfaces import ISeqRecordContainer 
     39from plone4bio.base.interfaces import ISeqRecordUploader 
    940 
    10 # TODO XXX 
     41# TODO: 
    1142def guess_dbtype(filename): 
    1243    return "GenBank" 
     
    3162 
    3263    def upload_data(self, data, dbtype):         
    33         # formatter =     self.request.locale.dates.getFormatter( 
    34         #    'dateTime', 'medium') 
    35         error = ISeqRecordContainer(self.context).loadData(data, dbtype) 
     64        error = ISeqRecordUploader(self.context).loadData(data, dbtype) 
    3665        if error: 
    3766            return error 
     
    6392            url = Acquisition.aq_parent(context).absolute_url() 
    6493        return url + '/@@load' 
    65  
  • plone4bio.base/trunk/src/plone4bio/base/browser/css/plone4bio.css

    r45 r171  
    11/* <dtml-with base_properties> */ 
    22 
     3/* plone4bio-controlpanel */ 
     4.fieldstyle-name { float: left; } 
     5.fieldstyle-pattern { float: left; } 
     6.fieldstyle-pattern input { width: 400px; } 
     7 
     8/* */ 
    39span.T { color: #f7d565; } 
    410span.I { color: #61b5ce; } 
  • plone4bio.base/trunk/src/plone4bio/base/browser/interfaces.py

    • Property svn:keywords set to Date Revision Author Id
    r45 r171  
    1 __author__ = """Mauro Amico <amico@biodec.com>""" 
     1# -*- coding: utf-8 -*- 
     2# 
     3# File: interfaces.py 
     4# 
     5# Copyright (c) 2010 by Mauro Amico (Biodec Srl) 
     6# 
     7# GNU General Public License (GPL) 
     8# 
     9# This program is free software; you can redistribute it and/or 
     10# modify it under the terms of the GNU General Public License 
     11# as published by the Free Software Foundation; either version 2 
     12# of the License, or (at your option) any later version. 
     13# 
     14# This program is distributed in the hope that it will be useful, 
     15# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     17# GNU General Public License for more details. 
     18# 
     19# You should have received a copy of the GNU General Public License 
     20# along with this program; if not, write to the Free Software 
     21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
     22# 02110-1301, USA. 
     23# 
     24# @version $Revision$: 
     25# @author  $Author$: 
     26# @date    $Date$: 
     27 
     28__author__ = """Mauro Amico <mauro@biodec.com>""" 
    229__docformat__ = 'plaintext' 
    330 
     
    532from zope.viewlet.interfaces import IViewletManager 
    633 
    7  
    8 class IBDMSiteForm(IViewletManager): 
    9         """ Marker interface for a Sequence """ 
    10  
    1134class ISequenceView(Interface): 
    12         """ Marker interface for a Sequence """ 
     35    """ Marker interface for a Sequence """ 
     36         
  • plone4bio.base/trunk/src/plone4bio/base/browser/predictor.py

    • Property svn:keywords set to Date Revision Author Id
    r128 r171  
    1414 
    1515from plone4bio.base import Plone4BioMessageFactory as _ 
    16 from plone4bio.base.browser.seqrecord import SeqRecordAddForm 
    1716from plone4bio.base.content.seqrecord import SeqRecord 
    1817from plone4bio.base.interfaces import ISeqRecord 
  • plone4bio.base/trunk/src/plone4bio/base/browser/seqrecord.py

    • Property svn:keywords set to Date Revision Author Id
    r117 r171  
    1 # 
    21from zope.formlib import form 
    32from zope.component import createObject 
    43 
    54from plone.app.form import base 
     5from plone.memoize.view import memoize 
    66from Products.CMFCore.utils import getToolByName 
    77from Products.Five import BrowserView 
     
    1212from plone4bio.base import Plone4BioMessageFactory as _ 
    1313 
    14 from Bio import SeqIO 
    15 from StringIO import StringIO 
    16  
    17  
    1814""" 
    1915class SeqRecordWidget(ObjectWidget): 
     
    2117    seq_widget = CustomWidgetFactory(ObjectWidget, SeqProxy) 
    2218""" 
    23  
    24 class SeqRecordAddForm(base.AddForm): 
    25     """Add form """ 
    26     form_fields = form.Fields(ISeqRecord) 
    27     # form_fields['seqrecord'].custom_widget = CustomWidgetFactory(SeqRecordWidget, SeqRecordProxy) 
    28     label = _(u"Add SeqRecord") 
    29     form_name = _(u"Add SeqRecord") 
    30     def create(self, data): 
    31         seqrecord = createObject(u"plone4bio.base.SeqRecord", title=data['title']) 
    32         form.applyChanges(seqrecord, self.form_fields, data) 
    33         return seqrecord 
    34  
    35 class SeqRecordEditForm(base.EditForm): 
    36     form_fields = form.Fields(ISeqRecord) 
    37     # form_fields['sequence'].field.readonly = True 
    38     # form_fields['seqrecord'].custom_widget = CustomWidgetFactory(SeqRecordWidget, SeqRecordProxy) 
    39     label = _(u"Edit SeqRecord") 
    40     form_name = _(u"Edit SeqRecord") 
    41  
    42 #TODO: adapter ??? 
    43 class SeqRecord2Genbank(BrowserView): 
    44     """ """ 
    45     def __call__(self): 
    46         io = StringIO() 
    47         # FIXME: 
    48         self.context.Description() 
    49         seqrecord = self.context.seqrecord 
    50         # the maximum length of locus name, for genbak format, is 16 
    51         seqrecord.name = seqrecord.name[:16] 
    52         # features 
    53         for f in seqrecord.features: 
    54             f.type = f.type.replace(" ", "_") 
    55         SeqIO.write([seqrecord, ], io, "genbank") 
    56         return io.getvalue() 
    57      
    58 #TODO: adapter ??? 
    59 class SeqRecord2Fasta(BrowserView): 
    60     """ """ 
    61     def __call__(self): 
    62         io = StringIO() 
    63         # FIXME: 
    64         self.context.Description() 
    65         SeqIO.write([self.context.seqrecord, ], io, "fasta") 
    66         return io.getvalue() 
    6719 
    6820#TODO: use viewlet 
     
    7931class SeqRecordDbxrefsView(BrowserView): 
    8032    """ """ 
     33     
     34    @property 
     35    @memoize 
     36    def urldict(self): 
     37        dbxrefpatterns_tool =  getToolByName(self.context, 'plone4bio_dbxrefpatterns') 
     38        if dbxrefpatterns_tool: 
     39            dbxref_patterns = dbxrefpatterns_tool.dbxref_patterns 
     40            return dict([(p.name, p.pattern) for p in dbxref_patterns]) 
     41        else: 
     42            # TODO: logger.warning ... 
     43            return {} 
     44    """             
     45    def __init__(self, *args, **kw): 
     46        super(SeqRecordDbxrefsView, self).__init__(*args, **kw) 
     47        self.dbxrefpatterns_tool =  getToolByName(self.context, 'plone4bio_dbxrefpatterns') 
     48        self.urldict = dict([(p.name, p.pattern)  
     49                for p in self.dbxrefpatterns_tool.dbxrefs_patterns]) 
     50    """ 
     51         
    8152    __call__ = ViewPageTemplateFile('templates/dbxrefs.pt') 
     53     
    8254    def getdbxref_url(self, dbxrefdb, key): 
    83         if urldict.has_key(dbxrefdb): 
     55        if self.urldict.has_key(dbxrefdb): 
    8456                if dbxrefdb == 'Internal': 
    8557                        dbid, accessionv = key.split(':') 
     
    9567                        cid = key.split('.')[-1] 
    9668                        org = key.split('.')[0] 
    97                         return urldict[dbxrefdb] % (org, cid) 
     69                        return self.urldict[dbxrefdb] % (org, cid) 
    9870                if dbxrefdb == 'Ensemble': 
    9971                        dbxrefdb = key[:4] 
     
    10779                        key = key.split('.')[0] 
    10880                ## Othewise 
    109                 return urldict[dbxrefdb] % key 
     81                return self.urldict[dbxrefdb] % key 
    11082 
    11183class SeqRecordView(BrowserView): 
    11284    """ """ 
    113     def Sequence(self, n=10, sep= ' '): 
    114         sequence = self.context.Sequence() 
    115         if n: 
    116             rvalue = '' 
    117             while(len(sequence)>n): 
    118                 rvalue = rvalue + sep + sequence[:n] 
    119                 sequence = sequence[n:] 
    120             rvalue = rvalue + sep + sequence 
    121             return rvalue.strip() 
    122         else: 
    123             return sequence 
    12485 
    12586class SeqRecordPredictors(BrowserView): 
     
    142103        self.tool(self.request.form['predictor'], self.context, store=True) 
    143104 
    144  
    145 #TODO: move on registry ? 
    146 urldict = { 
    147        'GO': 'http://amigo.geneontology.org/cgi-bin/amigo/term-details.cgi?term=%s', 
    148        'EMBL':'http://www.ebi.ac.uk/cgi-bin/sva/sva.pl/?search=Go!&query=%s', 
    149        'Ensembl' : 'http://www.ensembl.org/Homo_sapiens/Gene/Summary?g=%s', 
    150        'ENSG' : 'http://www.ensembl.org/Homo_sapiens/Gene/Summary?g=%s', 
    151        'ENST' : 'http://www.ensembl.org/Homo_sapiens/Transcript/Summary?t=%s', 
    152        'ENSP' : 'http://www.ensembl.org/Homo_sapiens/Transcript/ProteinSummary?p=%s', 
    153        'GermOnline' : 'http://www.ensembl.org/Homo_sapiens/Gene/Summary?g=%s', 
    154        'OTTHUMG' : 'http://vega.sanger.ac.uk/Homo_sapiens/geneview?gene=%s', 
    155        'OTTT' : 'http://vega.sanger.ac.uk/Homo_sapiens/transview?transcript=%s', 
    156        'OTTP' : 'http://vega.sanger.ac.uk/Homo_sapiens/protview?peptide=%s', 
    157        'shares_CDS_with_OTTT' : 'http://vega.sanger.ac.uk/Homo_sapiens/transview?transcript=%s', 
    158        'EMBL' : 'http://www.ebi.ac.uk/cgi-bin/sva/sva.pl/?search=Go!&query=%s', 
    159        'PUBMED' : 'http://www.ncbi.nlm.nih.gov/sites/entrez/%s', 
    160        'EntrezGene' : 'http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&term=%s', 
    161        'GeneID' : 'http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&term=%s', 
    162        'IPI' : 'http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+[IPI-AllText:%s*]+-view+SwissEntry', 
    163        'InterPro' : 'http://www.ebi.ac.uk/interpro/ISearch?query=%s', 
    164        'PIR' : 'http://pir.georgetown.edu/cgi-bin/textsearch.pl?submit.x=0&submit.y=0&field0=ALL&search=1&query0=%s', 
    165        'PIRSF' : 'http://pir.georgetown.edu/cgi-bin/ipcSF?id=%s', 
    166        'PROSITE' : 'http://www.expasy.ch/prosite/%s', 
    167        'Pfam' : 'http://pfam.sanger.ac.uk//family/%s', 
    168        'SMART' : 'http://smart.embl-heidelberg.de/smart/do_annotation.pl?BLAST=DUMMY&DOMAIN=%s', 
    169        'Uniprot/SPTREMBL' : 'http://www.uniprot.org/uniprot/%s', 
    170        'Uniprot/SWISSPROT' : 'http://www.uniprot.org/uniprot/%s', 
    171        'Uniprot/Varsplic' : 'http://www.uniprot.org/uniprot/%s', 
    172        'HGNC_NAME' : 'http://www.genenames.org/data/hgnc_data.php?match=%s', 
    173        'HGNC_ID' : 'http://www.genenames.org/data/hgnc_data.php?hgnc_id=%s', 
    174        'HGNC' : 'http://www.genenames.org/data/hgnc_data.php?hgnc_id=%s', 
    175        'RefSeq' : 'http://www.ncbi.nlm.nih.gov/protein/%s', 
    176        'RefSeq_dna' : 'http://www.ncbi.nlm.nih.gov/nuccore/%s', 
    177        'RefSeq_peptide' : 'http://www.ncbi.nlm.nih.gov/protein/%s', 
    178        'CCDS' : 'http://www.ncbi.nlm.nih.gov/projects/CCDS/CcdsBrowse.cgi?REQUEST=ALLFIELDS&DATA=%s', 
    179        'UniGene' : 'http://www.ncbi.nlm.nih.gov/UniGene/clust.cgi?ORG=%s&CID=%s', 
    180        'UniSTS' : 'http://www.ncbi.nlm.nih.gov/genome/sts/sts.cgi?uid=%s', 
    181        'PANTHER' : 'http://www.pantherdb.org/panther/family.do?clsAccession=%s', 
    182        'protein_id' : 'http://www.ncbi.nlm.nih.gov/protein/%s', 
    183        'HPRD' : 'http://www.hprd.org/resultsQuery?multiplefound=&prot_name=&external=Ref_seq&accession_id=&gene_symbol=&chromo_locus=&function=&ptm_type=&localization=&domain=&motif=&expression=&prot_start=&prot_end=&limit=0&mole_start=&mole_end=&disease=&query_submit=Search&hprd=%s', 
    184        'PeptideAtlas' : 'https://db.systemsbiology.net/sbeams/cgi/PeptideAtlas/Search?action=GO&build_type_name=Any&all_fields=on&search_key=%s', 
    185        'PDB' : 'http://www.rcsb.org/pdb/explore/explore.do?structureId=%s', 
    186        'CDD' : 'http://www.ncbi.nlm.nih.gov/sites/entrez/query.fcgi?db=cdd&term=%s', 
    187        'PRINTS' : 'http://www.bioinf.manchester.ac.uk/cgi-bin/dbbrowser/sprint/searchprintss.cgi?display_opts=Prints&category=None&queryform=false&prints_accn=%s', 
    188        'PharmGKB' : 'http://www.pharmgkb.org/do/serve?objId=%s', 
    189        'KEGG' : 'http://www.genome.jp/dbget-bin/www_bget?%s', 
    190        'MIM' : 'http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=%s', 
    191        'MIM_GENE' : 'http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=%s', 
    192        'MIM_MORBID' : 'http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=%s', 
    193        'PDBsum' : 'http://www.ebi.ac.uk/thornton-srv/databases/cgi-bin/pdbsum/GetPage.pl?template=main.html&EBI=TRUE&pdbcode=%s', 
    194        'UCSC' : 'http://genome.ucsc.edu/cgi-bin/hgGene?hgg_prot=Q9HAU5&hgg_chrom=chr10&hgg_start=12002026&hgg_end=12124814&hgg_type=knownGene&db=hg18&hgg_gene=%s', 
    195        'MEROPS' : 'http://merops.sanger.ac.uk/cgi-bin/make_frame_file?id=%s', 
    196        'GI' : 'http://www.ncbi.nlm.nih.gov/protein/%s', 
    197        'Internal' : '', 
    198 } 
  • plone4bio.base/trunk/src/plone4bio/base/browser/templates/seqrecord.pt

    r149 r171  
    6262 
    6363    <dl class="enableFormTabbing"> 
     64        <div tal:replace="structure provider:plone4bio.SeqRecordViewletManager" /> 
    6465                <dt id="fieldsetlegend-annotations" tal:condition="context/annotations">Annotations</dt> 
    6566        <dd id="fieldset-annotations" tal:condition="context/annotations" tal:content="structure here/@@annotations" />       
     
    6869        <dt id="fieldsetlegend-dbxrefs" tal:condition="context/dbxrefs">Dbxrefs</dt> 
    6970        <dd id="fieldset-dbxrefs" tal:condition="context/dbxrefs" tal:content="structure here/@@dbxrefs" /> 
    70                 <dt id="fieldsetlegend-sequence">Sequences</dt> 
    71         <dd id="fieldset-sequence"> 
    72                         <table class="listing" summary="Sequence" 
    73                                 tal:define="seqstatistics context/SeqStatistics; 
    74                                           statistickeys python:seqstatistics.keys();"> 
    75                                 <tr> 
    76                                         <th colspan="2">Statistics</th> 
    77                                         <th>Main Sequence</th> 
    78                                 </tr> 
    79                                 <tr class="odd"> 
    80                                         <td>Length</td> 
    81                                         <td tal:content="context/sequence/__len__" /> 
    82                                         <td rowspan="2"><code class="code" tal:content="view/Sequence" /></td> 
    83                         </tr> 
    84                         <tr tal:attributes="class python:'even';" tal:condition="python:seqstatistics.has_key('Composition')"> 
    85                                 <td colspan="2" tal:define="complabels python:seqstatistics['Composition'].keys(); 
    86                                                             labelsort python:complabels.sort();"> 
    87                                                 <dl tal:attributes="id string:group-${complabels}" class="collapsible inline collapsedOnLoad"> 
    88                                                 <dt class="collapsibleHeader" tal:content="string:Composition">Composition</dt> 
    89                                                 <dd class="collapsibleContent"> 
    90                                                 <ul tal:repeat="complabel complabels"> 
    91                                                         <li><span tal:content="python:seqstatistics['Composition'][complabel]" /></li> 
    92                                                 </ul> 
    93                                                 </dd> 
    94                                                 </dl> 
    95                                 </td> 
    96                         </tr> 
    97                         </table> 
    98  
    99  
    100                  
    101         </dd> 
    10271            <dt id="fieldsetlegend-references" tal:condition="context/annotations/references|nothing">References</dt> 
    10372        <dd id="fieldset-references"  tal:condition="context/annotations/references|nothing"> 
  • plone4bio.base/trunk/src/plone4bio/base/configure.zcml

    r161 r171  
    1515    <include package=".png" /> 
    1616    <include package=".tool" /> 
     17    <include package=".controlpanel" /> 
    1718 
    1819    <class class="Products.ATContentTypes.content.folder.ATFolder"> 
     
    2829    </class> 
    2930 
    30     <adapter factory=".atct.UploadingFileFactory" /> 
     31    <adapter 
     32        for="Products.ATContentTypes.interface.IATFolder" 
     33        provides=".interfaces.ISeqRecordUploader" 
     34        factory=".atct.UploadingFileFactory" 
     35      /> 
     36 
     37    <adapter 
     38        for="Products.ATContentTypes.interfaces.folder.IATBTreeFolder" 
     39        provides=".interfaces.ISeqRecordUploader" 
     40        factory=".atct.UploadingFileFactory" 
     41      /> 
    3142     
    3243    <!-- Register GenericSetup profile used for installation --> 
  • plone4bio.base/trunk/src/plone4bio/base/content/__init__.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/content/configure.zcml

    r149 r171  
    1212      /> 
    1313 
    14     <utility 
    15         component=".seqrecord.seqRecordFactory" 
    16         name="plone4bio.base.SeqRecord" 
    17         /> 
    18  
    19     <!-- 
    20     <adapter factory=".seqrecord.SeqRecordSearchableText" /> 
    21     --> 
    22  
    2314    <class class=".seqrecord.SeqRecord"> 
    2415        <require 
     
    3223    </class> 
    3324 
    34     <!-- 
    35     <five:implements 
    36       class=".seqrecord.SeqRecord" 
    37       interface="plone.app.content.interfaces.INameFromTitle" 
    38       /> 
    39     --> 
    40  
    4125</configure> 
  • plone4bio.base/trunk/src/plone4bio/base/content/seqrecord.py

    • Property svn:keywords set to Date Revision Author Id
    r152 r171  
    1 __author__ = '''Mauro Amico <m@biodec.com>''' 
     1# -*- coding: utf-8 -*- 
     2# 
     3# File: seqrecord.py 
     4# 
     5# Copyright (c) 2010 by Mauro Amico (Biodec Srl) 
     6# 
     7# GNU General Public License (GPL) 
     8# 
     9# This program is free software; you can redistribute it and/or 
     10# modify it under the terms of the GNU General Public License 
     11# as published by the Free Software Foundation; either version 2 
     12# of the License, or (at your option) any later version. 
     13# 
     14# This program is distributed in the hope that it will be useful, 
     15# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     17# GNU General Public License for more details. 
     18# 
     19# You should have received a copy of the GNU General Public License 
     20# along with this program; if not, write to the Free Software 
     21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
     22# 02110-1301, USA. 
     23# 
     24# @version $Revision$: 
     25# @author  $Author$: 
     26# @date    $Date$: 
     27 
     28__author__ = '''Mauro Amico <mauro@biodec.com>''' 
    229__docformat__ = 'plaintext' 
    330 
     
    1643# from plone.memoize.instance import memoize 
    1744 
     45from AccessControl import ClassSecurityInfo 
     46 
    1847# from Products.CMFCore.WorkflowCore import WorkflowException 
    1948# from Products.CMFCore.utils import getToolByName 
    2049# from OFS.OrderSupport import OrderSupport 
    2150 
     51from Products.ATContentTypes.content.base import ATCTContent 
     52from Products.ATContentTypes.content.schemata import ATContentTypeSchema 
     53 
     54from Products.Archetypes import atapi 
     55 
    2256# biopython 
    2357from Bio.Seq import Seq as BioSeq 
     
    2660# plone4bio 
    2761from plone4bio.base import Plone4BioMessageFactory as _ 
    28 from plone4bio.base.interfaces import ISeqRecord, ISeqRecordProxy, ISeqProxy 
     62from plone4bio.base.interfaces import ISeqRecord #, ISeqRecordProxy, ISeqProxy 
    2963 
    3064import logging 
    3165logger = logging.getLogger('plone4bio') 
    3266 
    33 #TODO: 
    34 class SeqProxy(BioSeq): 
    35     implements(ISeqProxy) 
    36     def _set_data(self, data): 
    37         self._data = data 
    38     data = property(fget=lambda self: unicode(self._data), fset=_set_data)         
    39     def __init__(self, data=u''): 
    40         super(SeqProxy, self).__init__(data) 
    41      
    42 #TODO: 
    43 class SeqRecordProxy(BioSeqRecord): 
    44     implements(ISeqRecordProxy) 
    45     def __init__(self, seq=None): 
    46         super(SeqRecordProxy, self).__init__(seq) 
    47  
    48 """ 
    49 class SeqRecordSearchableText(object): 
    50     adapts(ISeqRecord) 
    51     implements(ISearchableText) 
    52  
    53     def __init__(self, seqrecord): 
    54         self.seqrecord = seqrecord 
    55  
    56     def getSearchableText(self): 
    57         return u' '.join( 
    58             unicode(v) for v in self.seqrecord.dbxrefs) 
    59 """ 
    60  
    61 # TODO 
    62 class SeqRecord(Item): 
    63     #TODO: move to zcml ??? 
    64     implements(ISeqRecord, ITTWLockable) #, INameFromTitle) 
     67 
     68SeqRecordSchema = ATContentTypeSchema.copy() + atapi.Schema(( 
     69    atapi.TextField("sequence", 
     70        required = True, 
     71        default_content_type = 'text/plain', 
     72        allowable_content_types = ('text/plain',), 
     73        widget = atapi.TextAreaWidget( 
     74            label = "sequence", 
     75            label_msgid = "sequence_label", 
     76            description = "Sequence", 
     77            description_msgid = "sequence_help", 
     78            i18n_domain = "plone4bio") 
     79    ), 
     80    atapi.StringField("alphabet", 
     81        required = True, 
     82        enforceVocabulary = True, 
     83        vocabulary = ["Bio.Alphabet.ProteinAlphabet", 
     84            "Bio.Alphabet.IUPAC.ExtendedIUPACProtein", 
     85            "Bio.Alphabet.IUPAC.IUPACProtein", 
     86        ], 
     87        widget = atapi.SelectionWidget( 
     88            label = "alphabet", 
     89            label_msgid = "alphabet_label", 
     90            description = "Alphabet", 
     91            description_msgid = "alphabet_help", 
     92            i18n_domain = "plone4bio") 
     93    ), 
     94    )) 
     95 
     96class SeqRecord(ATCTContent): 
    6597    portal_type='SeqRecord' 
    6698 
    67     # seqrecord = FieldProperty(ISeqRecord['seqrecord']) 
    68     # title = SeqRecordProperty('name', u'') 
    69     title = FieldProperty(ISeqRecord['title']) 
    70     sequence = FieldProperty(ISeqRecord['sequence']) 
    71     alphabet = FieldProperty(ISeqRecord['alphabet']) 
    72     dbxrefs = FieldProperty(ISeqRecord['dbxrefs']) 
    73     # annotations = FieldProperty(ISeqRecord['annotations']) 
    74     annotations = {} 
     99    implements(ISeqRecord) 
     100 
     101    security = ClassSecurityInfo() 
     102    schema = SeqRecordSchema 
     103    _at_rename_after_creation = True 
     104 
     105    annotations = {} # TODO 
    75106    features = [] # TODO 
    76  
    77     def __init__(self, *args, **kwargs): 
    78         seqrecord = None 
    79         if kwargs.has_key('seqrecord'): 
    80             seqrecord = kwargs['seqrecord'] 
    81             del(kwargs['seqrecord']) 
    82         if kwargs.has_key('parent'): 
    83             parent = kwargs['parent'] 
    84             del(kwargs['parent']) 
    85         kwargs['title'] = unicode(kwargs.get('title', '')) 
    86         super(SeqRecord, self).__init__(*args, **kwargs) 
    87         if seqrecord: 
    88             self.sequence = unicode(seqrecord.seq.data) 
    89             self.alphabet = "%s.%s" % (seqrecord.seq.alphabet.__class__.__module__, seqrecord.seq.alphabet.__class__.__name__) 
    90             self.features = copy.deepcopy(seqrecord.features) 
     107    dbxrefs = [] # TODO 
    91108 
    92109    def Accession(self): 
     
    102119            return None 
    103120 
    104     @property 
    105     def seqrecord(self): 
     121    # override this function on different implementation (e.g. biosql) 
     122    def getSeqRecord(self): 
    106123        """ 
    107124            id 
     
    123140        seqr.features = self.features 
    124141        return seqr 
     142     
     143    @property 
     144    def seqrecord(self): 
     145        self.getSeqRecord() 
    125146 
    126147    def alphabetClass(self): 
    127         alphabet = self.alphabet 
     148        alphabet = self.getAlphabet() 
    128149        __traceback_info__ = alphabet 
    129150        parts = alphabet.split( '.' ) 
     
    150171        return obj 
    151172 
    152     # override this function on different implementation (e.g. biosql) 
    153     def _getSeqRecord(self): 
    154         """ """ 
    155         return self.seqrecord 
    156  
    157     """ 
    158     @property 
    159     def title(self): 
    160         ## TODO: defire un criterio per generare un Title: 
    161         ## soluzione probabile e' utlizzare i campi accession 
    162         ## e name del seqrecord in cui poter mettere HGNC e/o 
    163         ## codice IPI 
    164         seqrecord =  self.__getSeqRecord__() 
    165         if seqrecord: 
    166             return seqrecord.name 
    167         else: 
    168             return u'' 
    169     """ 
    170      
    171     """     
    172     #TODO: ???     
    173     def Title(self): 
    174         return self.title 
    175     """ 
    176  
    177173    def Sequence(self): 
    178         return self.sequence 
     174        return self.getSequence() 
    179175         
    180176    """ 
     
    284280                           'ncbi_cds_calculated_protein', 
    285281                           'ensembl_calculated_protein', 
    286                    'uniprot_sequence'] 
     282                           'uniprot_sequence'] 
    287283        annotation_sequences = {} 
    288284        for t in proteintags: 
     
    307303    """ 
    308304 
    309 seqRecordFactory = Factory(SeqRecord, title=_(u"Create a new SeqRecord")) 
     305# seqRecordFactory = Factory(SeqRecord, title=_(u"Create a new SeqRecord")) 
     306 
     307atapi.registerType(SeqRecord, 'plone4bio.base') 
  • plone4bio.base/trunk/src/plone4bio/base/interfaces.py

    • Property svn:keywords set to Date Revision Author Id
    r113 r171  
     1# -*- coding: utf-8 -*- 
     2# 
     3# File: interfaces.py 
     4# 
     5# Copyright (c) 2010 by Mauro Amico (Biodec Srl) 
     6# 
     7# GNU General Public License (GPL) 
     8# 
     9# This program is free software; you can redistribute it and/or 
     10# modify it under the terms of the GNU General Public License 
     11# as published by the Free Software Foundation; either version 2 
     12# of the License, or (at your option) any later version. 
     13# 
     14# This program is distributed in the hope that it will be useful, 
     15# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     17# GNU General Public License for more details. 
     18# 
     19# You should have received a copy of the GNU General Public License 
     20# along with this program; if not, write to the Free Software 
     21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
     22# 02110-1301, USA. 
     23# 
     24# @version $Revision$: 
     25# @author  $Author$: 
     26# @date    $Date$: 
     27 
    128from zope.interface import Interface 
    2 from zope import schema 
     29from zope.schema import TextLine 
    330 
    4 from plone4bio.base import Plone4BioMessageFactory as _ 
    5 from plone4bio.base import fields 
    6  
    7 class ISeqProxy(Interface): 
    8     #TODO: readonly attribute doesn't work !!!! (????) 
    9     data = schema.Text(title=_(u"Sequence"), 
    10                                description=_(u"The sequence"), 
    11                                required=True, 
    12                                readonly=True) 
    13  
    14 class ISeqRecordProxy(Interface): 
    15     name = schema.TextLine(title=_(u"Name"), 
    16                             description=_(u"Name of the sequence"), 
    17                             required=True) 
    18     id = schema.TextLine(title=_(u"identifier"), required=True) 
    19     accession = schema.TextLine(title=_(u"accession"), required=True) 
    20     #TODO: readonly attribute doesn't work !!!! (????) 
    21     seq = schema.Object(title=_(u"Sequence"), 
    22                                description=_(u"Sequence"), 
    23                                schema = ISeqProxy, 
    24                                readonly=True) 
    2531 
    2632class ISeqRecord(Interface): 
    27     """ Biopython's SeqRecord ... Plone4Bio 
    28     seqrecord = schema.Object(title=_(u"SeqRecord"), 
    29                                description=_(u"SeqRecord"), 
    30                                schema = ISeqRecordProxy) 
    31     """ 
    32     # TODO: custom fields/widgets/validators 
    33     title = schema.TextLine(title=_(u"name"), required=True, default=u'') 
    34     description = schema.Text(title=_(u"Description")) 
    35     # accession = schema.TextLine(title=_(u"accession"), required=True, default=u'') 
    36     sequence = fields.Sequence(title=_(u"Sequence"),  
    37                            description=_(u"The sequence"), 
    38                            required=True, 
    39                            default=u'') 
     33    """ """ 
    4034 
    41     # TODO: vocabulary 
    42     alphabet = fields.ChoiceWORM(title=_(u"Alphabet"), values = ["Bio.Alphabet.ProteinAlphabet", 
    43                                                              "Bio.Alphabet.IUPAC.ExtendedIUPACProtein", 
    44                                                              "Bio.Alphabet.IUPAC.IUPACProtein", 
    45                                                              ]) 
    4635 
    47     dbxrefs = schema.List(title=_(u"Dbxrefs"), value_type=schema.TextLine(title=_(u"dbxref")), required=False) 
    48     #TODO: annotation value will be also a list ... 
    49     #TODO: there is no default widget for Dict 
    50     #annotations = schema.Dict(title=_(u"Annotations"), 
    51     #                          key_type=schema.TextLine(title=_(u"key")), 
    52     #                          value_type=schema.TextLine(title=_(u"value"))) 
     36class ISeqRecordUploader(Interface): 
     37    """ """ 
     38    def loadData(self, data, data_type): 
     39        """ """ 
     40 
    5341 
    5442class ISeqRecordContainer(Interface): 
    5543    """ """ 
    5644 
     45 
    5746class IPredictor(Interface): 
    5847    """ """ 
    5948 
     49 
     50#TODO: remove 
     51class IPlone4BioConfiguration(Interface): 
     52    """ """ 
     53 
     54 
    6055class IPredictorTool(Interface): 
    6156    """ """ 
     57     
     58     
     59class IDbxrefPatternsTool(Interface): 
     60    """ """ 
     61     
     62class IDbxrefPattern(Interface): 
     63    """ """ 
     64    name = TextLine(title=u"name") 
     65    pattern = TextLine(title=u"pattern") 
     66 
     67 
  • plone4bio.base/trunk/src/plone4bio/base/png/__init__.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/png/cluetip/cluetip/jquery.cluetip.css

    r45 r171  
    1414  height: 11px; 
    1515  position: absolute; 
    16   background-image: url(wait.gif); 
     16  background-image: url(++resource++jquery.cluetip.images/wait.gif); 
    1717} 
    1818.cluetip-arrows { 
  • plone4bio.base/trunk/src/plone4bio/base/png/configure.zcml

    r45 r171  
    33    xmlns:browser="http://namespaces.zope.org/browser" 
    44    i18n_domain="plone4bio"> 
    5      
     5 
    66    <adapter factory=".seqrecord.seqrecordPNG" /> 
    77    <adapter factory=".seqrecord.seqrecordImagemap" /> 
     
    3939        file="cluetip/hoverIntent/jquery.hoverIntent.minified.js" 
    4040        /> 
     41    <browser:resourceDirectory 
     42        name="jquery.cluetip.images" 
     43        directory="cluetip/cluetip/images" 
     44        /> 
    4145    <!-- cluetip --> 
    4246 
  • plone4bio.base/trunk/src/plone4bio/base/png/interfaces.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/png/seqrecord.py

    • Property svn:keywords set to Date Revision Author Id
    r159 r171  
    1818 
    1919try: 
    20     from plone4bio.graphics.seqrecord import SeqRecordDrawer 
    21     has_plone4bio_graphics = True 
     20    from biograpy.seqrecord import SeqRecordDrawer 
     21    HAS_BIOGRAPY = True 
    2222except ImportError: 
    23     logger.warning("missing plone4bio.graphics") 
     23    logger.warning("Missing biograpy. Use BioPerl") 
    2424    # BioPerl 
    2525    import subprocess 
    2626    import os 
    27     has_plone4bio_graphics = False 
    28  
     27    HAS_BIOGRAPY = False 
    2928 
    3029@adapter(ISeqRecord, IRequest) 
     
    3231def seqrecordImagemap(context, request): 
    3332    # FIXME: XXX 
    34     context.Description() 
    35     seqrecord = context.seqrecord 
    36     if has_plone4bio_graphics: 
     33    # context.Description() 
     34    seqrecord = context.getSeqRecord() 
     35    if HAS_BIOGRAPY: 
    3736        imagemap = """<map name="graphicsmap" id="graphicsmap">\n""" 
    3837        for box in SeqRecordDrawer(seqrecord, fig_width=1500).boxes(): 
     
    6160            f.type = f.type.replace(" ", "_") 
    6261        SeqIO.write([seqrecord, ], genbank, "genbank") 
    63         (stdoutdata, stderrdata) = graphics.communicate(genbank.getvalue()) 
    64         return stdoutdata 
     62        try: 
     63            (stdoutdata, stderrdata) = graphics.communicate(genbank.getvalue()) 
     64            return stdoutdata 
     65        except: 
     66            logger.exception('error with bioperl') 
     67            return None 
    6568 
    6669@adapter(ISeqRecord, IRequest) 
     
    6871def seqrecordPNG(context, request): 
    6972    # FIXME: XXX 
    70     context.Description() 
    71     seqrecord = context.seqrecord 
    72     if has_plone4bio_graphics: 
     73    # context.Description() 
     74    seqrecord = context.getSeqRecord() 
     75    if HAS_BIOGRAPY: 
    7376        imgdata=StringIO() 
    7477        SeqRecordDrawer(seqrecord, fig_width=1500).save(imgdata, format='PNG') 
     
    8083        perlpath = os.sep.join((os.path.dirname(__file__), "perl")) 
    8184        cmd = ["perl", "-I"+ perlpath, os.sep.join((perlpath, "graphics-cmd.pl")), "-"] 
    82         graphics = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE) 
    8385        genbank=StringIO() 
    8486        seqrecord.name = seqrecord.name[:16] 
    8587        for f in seqrecord.features: 
    8688            f.type = f.type.replace(" ", "_") 
    87             SeqIO.write([seqrecord, ], genbank, "genbank") 
    88         (stdoutdata, stderrdata) = graphics.communicate(genbank.getvalue()) 
    89         return stdoutdata 
     89        SeqIO.write([seqrecord, ], genbank, "genbank") 
     90        graphics = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE) 
     91        try: 
     92            (stdoutdata, stderrdata) = graphics.communicate(genbank.getvalue()) 
     93            return stdoutdata 
     94        except: 
     95            logger.exception('error with bioperl') 
     96            return None 
    9097 
    9198class PNGFeaturesView(BrowserPage): 
  • plone4bio.base/trunk/src/plone4bio/base/predictor.py

    • Property svn:keywords set to Date Revision Author Id
    r54 r171  
    1414from plone4bio.base.interfaces import ISeqRecord 
    1515 
     16 
    1617def make_config_persistent(kwargs): 
    1718    """ iterates on the given dictionnary and replace list by persistent list, 
     
    2627            kwargs[key] = p_value 
    2728 
     29 
    2830def make_config_nonpersistent(kwargs): 
    2931    """ iterates on the given dictionary and replace ListClass by python List, 
     
    3739            p_value = list(value) 
    3840            kwargs[key] = p_value 
     41 
    3942 
    4043class Predictor(SimpleItem): 
     
    104107        klass = self.predictorclass() 
    105108        __traceback_info__ = klass 
    106         parts = klass.split( '.' ) 
     109        parts = klass.split('.') 
    107110        if not parts: 
    108111            raise ValueError, "incomplete klass name: %s" % klass 
     
    110113        while parts_copy: 
    111114            try: 
    112                 module = __import__( '.'.join( parts_copy ) ) 
     115                module = __import__('.'.join(parts_copy)) 
    113116                break 
    114117            except ImportError: 
    115118                # Reraise if the import error was caused inside the imported file 
    116                 if sys.exc_info()[2].tb_next is not None: raise 
    117                 del parts_copy[ -1 ] 
     119                if sys.exc_info()[2].tb_next is not None: 
     120                    raise 
     121                del parts_copy[-1] 
    118122                if not parts_copy: 
    119123                    return None 
    120         parts = parts[ 1: ] # Funky semantics of __import__'s return value 
     124        parts = parts[1:] # Funky semantics of __import__'s return value 
    121125        obj = module 
    122126        for part in parts: 
    123127            try: 
    124                 obj = getattr( obj, part ) 
     128                obj = getattr(obj, part) 
    125129            except AttributeError: 
    126130                return None 
    127131        self._v_predictor = obj() 
    128132 
    129     def run(self, obj, context=None, store=False, argv=([],{})): 
     133    def run(self, obj, context=None, store=False, argv=([], {})): 
    130134        """ """ 
    131135        assert type(argv[0]) == list 
     
    134138            self._load_predictor() 
    135139        if ISeqRecord.providedBy(obj): 
    136             newseqr = self._v_predictor.run(obj.seqrecord, *argv[0], **argv[1]) 
     140            newseqr = self._v_predictor.run(obj.getSeqRecord(), *argv[0], **argv[1]) 
    137141            if store: 
    138142                #TODO: need locking? 
  • plone4bio.base/trunk/src/plone4bio/base/profiles/default/componentregistry.xml

    r45 r171  
    11<?xml version="1.0"?> 
    22<componentregistry> 
    3  <adapters/> 
    4  <utilities> 
    5   <utility 
    6      interface="plone4bio.base.interfaces.IPredictorTool" 
    7      object="plone4bio_predictors"/> 
    8  </utilities> 
     3    <adapters/> 
     4    <utilities> 
     5        <utility 
     6            interface="plone4bio.base.interfaces.IPredictorTool" 
     7            object="plone4bio_predictors" /> 
     8        <utility 
     9            interface="plone4bio.base.interfaces.IDbxrefPatternsTool" 
     10            object="plone4bio_dbxrefpatterns" /> 
     11    </utilities> 
    912</componentregistry> 
    1013 
  • plone4bio.base/trunk/src/plone4bio/base/profiles/default/metadata.xml

    r161 r171  
    11<?xml version="1.0"?> 
    22<metadata> 
    3   <version>1.0.1</version> 
     3  <version>1.1.0rc1</version> 
    44</metadata> 
    55 
  • plone4bio.base/trunk/src/plone4bio/base/profiles/default/toolset.xml

    r45 r171  
    33 <required tool_id="plone4bio_predictors" 
    44           class="plone4bio.base.tool.PredictorTool"/> 
     5 <required tool_id="plone4bio_dbxrefpatterns" 
     6           class="plone4bio.base.tool.DbxrefPatternsTool"/> 
    57</tool-setup> 
    68 
  • plone4bio.base/trunk/src/plone4bio/base/profiles/default/types/SeqRecord.xml

    r45 r171  
    88 <property name="content_icon">++resource++plone4bio.images/sequence_icon.png</property> 
    99 <property name="content_meta_type">SeqRecord</property> 
    10  <property name="product"></property> 
    11  <property name="factory">plone4bio.base.SeqRecord</property> 
     10 <property name="product">plone4bio.base</property> 
     11 <property name="factory">addSeqRecord</property> 
    1212 <property name="immediate_view">@@view</property> 
    1313 <property name="global_allow">True</property> 
     
    1717 <alias from="(Default)" to="@@view"/> 
    1818 <alias from="view" to="@@view"/> 
     19 <alias from="edit" to="atct_edit"/> 
    1920 <action title="View" action_id="view" category="object" condition_expr="" 
    2021    url_expr="string:${object_url}" visible="True"> 
     
    2425    url_expr="string:${object_url}/edit" visible="True"> 
    2526  <permission value="Modify portal content"/> 
    26  </action>  
     27 </action> 
    2728 <action title="Predictors" action_id="predictors" category="object" condition_expr="" 
    2829    url_expr="string:${object_url}/predictors" visible="True"> 
  • plone4bio.base/trunk/src/plone4bio/base/tests/__init__.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/tests/base.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/tests/test_integration.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/src/plone4bio/base/tool/__init__.py

    • Property svn:keywords set to Date Revision Author Id
    r128 r171  
    11from predictor import PredictorTool 
    22PredictorTool # make pyflakes happy 
     3 
     4from dbxref import DbxrefPatternsTool 
     5DbxrefPatternsTool # make pyflakes happy 
  • plone4bio.base/trunk/src/plone4bio/base/tool/configure.zcml

    r45 r171  
    1111      /> 
    1212 
     13  <adapter 
     14      factory=".exportimport.DbxrefPatternsToolXMLAdapter" 
     15      provides="Products.GenericSetup.interfaces.IBody" 
     16      for="..interfaces.IDbxrefPatternsTool 
     17           Products.GenericSetup.interfaces.ISetupEnviron" 
     18      /> 
     19 
    1320    <gs:importStep 
    1421        name="plone4bio-settings-import" 
    1522        title="Plone4Bio Import" 
    1623        description="" 
    17         handler=".exportimport.importPredictors" 
     24        handler=".exportimport.importSettings" 
    1825    /> 
    1926 
     
    2229        title="Plone4Bio Export" 
    2330        description="" 
    24         handler=".exportimport.exportPredictors" 
     31        handler=".exportimport.exportSettings" 
    2532    /> 
    2633 
  • plone4bio.base/trunk/src/plone4bio/base/tool/exportimport.py

    • Property svn:keywords set to Date Revision Author Id
    r45 r171  
    88 
    99from plone4bio.base.interfaces import IPredictorTool 
     10from plone4bio.base.interfaces import IDbxrefPatternsTool 
     11from plone4bio.base.tool.dbxref import DbxrefPattern 
     12 
     13 
     14class DbxrefPatternsToolXMLAdapter(XMLAdapterBase): 
     15    __used_for__ = IDbxrefPatternsTool 
     16    _LOGGER_ID = 'plone4bio_dbxrefpatterns' 
     17 
     18    def _exportNode(self): 
     19        """Export the object as a DOM node""" 
     20        root = self._doc.createElement('plone4bio') 
     21        child = self._doc.createElement('dbxrefpatterns') 
     22        for p in getattr(self.context, 'dbxrefs_patterns', []):             
     23            node = self._doc.createElement('pattern') 
     24            node.setAttribute('name', p.name) 
     25            node.appendChild(self._doc.createTextNode(p.pattern)) 
     26            child.appendChild(node)         
     27        root.appendChild(child) 
     28        self._logger.info('Plone4Bio dbxref patterns tool exported.') 
     29        return root 
     30 
     31    def _importNode(self, node): 
     32        """Import the object from the DOM node""" 
     33        if self.environ.shouldPurge(): 
     34            self.context.dbxref_patterns = [] 
     35            self._logger.info('Plone4Bio dbxref patterns tool purged.') 
     36        # BBB: manage as dict 
     37        dbxref_patterns = {}  
     38        for child in node.childNodes: 
     39            if child.nodeName == 'dbxrefpatterns': 
     40                for pnode in child.childNodes: 
     41                    if pnode.nodeName == 'pattern': 
     42                        dbxref_patterns[pnode.getAttribute('name')] = '\n'.join([n.toxml() for n in pnode.childNodes]) 
     43        dbxref_patterns.update(dict([(p.name, p.pattern)  
     44                for p in self.context.dbxref_patterns])) 
     45        self.context.dbxref_patterns = [DbxrefPattern(name, pattern) for (name, pattern) in dbxref_patterns.items()] 
     46        self._logger.info('Plone4Bio dbxref patterns tool imported.') 
    1047 
    1148class PredictorToolXMLAdapter(XMLAdapterBase): 
     
    68105        return child 
    69106 
    70 def importPredictors(context): 
     107def importSettings(context): 
    71108    """Import tool settings from an XML file. 
    72109    """ 
    73110    site = context.getSite() 
    74111    tool = getToolByName(site, 'plone4bio_predictors', None) 
    75     if tool is None: 
    76         logger = context.getLogger('plone4bio_predictors') 
    77         logger.info('Nothing to import.') 
    78         return 
    79     importObjects(tool, '', context) 
     112    if tool: 
     113        importObjects(tool, '', context) 
     114    tool = getToolByName(site, 'plone4bio_dbxrefpatterns', None) 
     115    if tool: 
     116        importObjects(tool, '', context) 
    80117 
    81 def exportPredictors(context): 
     118def exportSettings(context): 
    82119    """Export tool settings as an XML file. 
    83120    """ 
    84121    site = context.getSite() 
    85122    tool = getToolByName(site, 'plone4bio_predictors', None) 
    86     if tool is None: 
    87         logger = context.getLogger('plone4bio_predictors') 
    88         logger.info('Nothing to export.') 
    89         return 
    90     exportObjects(tool, '', context) 
     123    if tool: 
     124        exportObjects(tool, '', context) 
     125    tool = getToolByName(site, 'plone4bio_dbxrefpatterns', None) 
     126    if tool: 
     127        exportObjects(tool, '', context) 
    91128 
    92129 
  • plone4bio.base/trunk/src/plone4bio/base/tool/predictor.py

    • Property svn:keywords set to Date Revision Author Id
  • plone4bio.base/trunk/test-plone-4.0.x.cfg

    r145 r171  
    44package-name = plone4bio.base 
    55versions = versions 
    6  
    7 [versions] 
    8 z3c.form = 2.2.0