예제 #1
0
class BioSQLDatabaseAddForm(AddFormBase):
    """Add form """
    form_fields = form.Fields(IBioSQLDatabase)
    label = _(u"Add BioSQLDatabase")
    form_name = _(u"Edit BioSQLDatabase")
    def create(self, data):
        root = self.context.getBioSQLRoot()
        dbserver = root.getDBServer()
        biodb = dbserver.new_database(data['id'], description=data.get("description", None))
        dbserver.commit()
        object = root[data['id']]
        # TODO: test catalog object
        return object
예제 #2
0
 def upload_data(self, data, dbtype):        
     error = ISeqRecordUploader(self.context).loadData(data, dbtype)
     if error:
         return error
     else:
         return _("Updated ${data} of ${dbtype} on ${date_time}",
              mapping={'date_time': repr(datetime.utcnow()),
                       'data': repr(data),
                       'dbtype': dbtype})
예제 #3
0
 def upload_data(self, data, dbtype):
     error = ISeqRecordUploader(self.context).loadData(data, dbtype)
     if error:
         return error
     else:
         return _("Updated ${data} of ${dbtype} on ${date_time}",
                  mapping={
                      'date_time': repr(datetime.utcnow()),
                      'data': repr(data),
                      'dbtype': dbtype
                  })
예제 #4
0
class BioSQLSeqRecordAddForm(AddFormBase):
    """Add form """
    label = _(u"Add BioSQLSeqRecord")
    form_name = _(u"Edit BioSQLSeqRecord")
    def create(self, data):
        seqrecord = SeqRecord(title=data['title'])
        form.applyChanges(seqrecord, self.form_fields, data)
        # TODO: id policy
        seqrecord.id = seqrecord.title
        # root = self.context.getBioSQLRoot()
        # dbserver = root.getDBServer()
        db = aq_inner(self.context.context)
        biodb = db.getDatabase(reload=True)
        # aq_inner(self.context.context).getDatabase().adaptor.conn.is_valid
        # dbserver.adaptor.conn.is_valid
        if biodb.load([seqrecord.seqrecord,]) == 1:
            bioentry_id = biodb.adaptor.last_id('bioentry')
            biodb.adaptor.commit()
            db.keys(reload=True)
            obj = db[str(bioentry_id)]
            obj._getSeqRecord(reload=True)
        else:
            obj = None
        return obj
예제 #5
0
class BioSQLSeqRecordEditForm(EditFormBase):
    """Edit form """
    form_fields = form.Fields(IBioSQLSeqRecord)
    label = _(u"Edit BioSQLSeqRecord")
    form_name = _(u"Edit BioSQLSeqRecord")
예제 #6
0
class BioSQLDatabaseEditForm(EditFormBase):
    """Edit form """
    form_fields = form.Fields(IBioSQLDatabase)
    label = _(u"Edit BioSQLDatabase")
    form_name = _(u"Edit BioSQLDatabase")
예제 #7
0
            return self.annotations['organism']
        else:
            return ""

    organism = property(fget=getOrganism)

    def getAccessions(self):
        if self.annotations.has_key('accessions'):
            return self.annotations['accessions']
        else:
            return ""

    accessions = property(fget=getAccessions)

    def getTaxonomy(self):
        if self.annotations.has_key('taxonomy'):
            return self.annotations['taxonomy']
        else:
            return []

    taxonomy = property(fget=getTaxonomy)

    def alphabetClass(self):
        return self.seqrecord.seq.alphabet.__class__


InitializeClass(BioSQLSeqRecord)

bioSQLSeqRecordFactory = Factory(BioSQLSeqRecord,
                                 title=_(u"Create a new BioSQL SeqRecord"))
예제 #8
0
    atapi.StringField("dsn",
                      required=True,
                      widget=atapi.StringWidget(label="dsn",
                                                label_msgid="dsn_label",
                                                description="DSN "
                                                "... "
                                                "...",
                                                description_msgid="dsn_help",
                                                i18n_domain="plone4bio")),
    atapi.StringField(
        "seqrecord_key",
        required=True,
        enforceVocabulary=True,
        default='bioentry_id',
        vocabulary=[
            ("bioentry_id", _(u"bioentry_id")),
            ("accession", _(u"accession")),
            ("version", _(u"accession.version")),
        ],
        widget=atapi.SelectionWidget(
            label="seqrecord_key",
            label_msgid="seqrecord_key_label",
            description=_(u"select the field name key for seqrecord uris"),
            description_msgid="seqrecord_key_help",
            i18n_domain="plone4bio")),
))


class BioSQLRoot(ATCTContent):
    portal_type = 'BioSQLRoot'
예제 #9
0
        # If 'spec' is specified, returns objects whose meta_type
        # matches 'spec'.
        assert spec is None, 'spec argument unsupported'
        return self.__iter__()

    security.declareProtected(access_contents_information, 'objectValues')
    def objectValues(self, spec=None):
        # Returns a list of actual subobjects of the current object.
        # If 'spec' is specified, returns only objects whose meta_type
        # match 'spec'.
        assert spec is None, 'spec argument unsupported'
        return self.itervalues()

    security.declareProtected(access_contents_information, 'objectItems')
    def objectItems(self, spec=None):
        # Returns a list of (id, subobject) tuples of the current object.
        # If 'spec' is specified, returns only objects whose meta_type match
        # 'spec'
        assert spec is None, 'spec argument unsupported'
        return self.iteritems()

# mix in selected methods from DictMixin
# We don't want *everything* because some cause problems for us
for m in ('__contains__', 'iterkeys', 'itervalues', 'values', 'items', 'get'):
    setattr(BioSQLDatabase, m, getattr(DictMixin, m).im_func)
    
InitializeClass(BioSQLDatabase)

bioSQLDatabaseFactory = Factory(BioSQLDatabase, title=_(u"Create a new BioSQL Database"))

예제 #10
0
class IPlone4BioConfigurationSchema(Interface):
    dbxref_patterns = List(title=u'Dbxref patterns',
                           description=_(u'help_dbxref_patterns', ),
                           value_type=Object(IDbxrefPattern,
                                             title=u"dbxref pattern"))
예제 #11
0
class Plone4BioControlPanel(ControlPanelForm):
    form_fields = FormFields(IPlone4BioConfigurationSchema)
    form_fields['dbxref_patterns'].custom_widget = DbxrefPatternsWidget
    label = _('Dbxrefs Patterns settings')
    description = _('Dbxrefs Patterns.')
    form_name = _('Dbxrefs Patterns')
예제 #12
0
    atapi.StringField("dsn",
        required = True,
        widget = atapi.StringWidget(
            label = "dsn",
            label_msgid = "dsn_label",
            description = "DSN "
                          "... "
                          "...",
            description_msgid = "dsn_help",
            i18n_domain = "plone4bio")
    ),
    atapi.StringField("seqrecord_key",
        required = True,
        enforceVocabulary = True,
        default = 'bioentry_id',
        vocabulary = [("bioentry_id", _(u"bioentry_id")),
                      ("accession", _(u"accession")),
                      ("version", _(u"accession.version")),
                     ],
        widget = atapi.SelectionWidget(
            label = "seqrecord_key",
            label_msgid = "seqrecord_key_label",
            description = _(u"select the field name key for seqrecord uris"),
            description_msgid = "seqrecord_key_help",
            i18n_domain = "plone4bio")
    ),
    ))

class BioSQLRoot(ATCTContent):
    portal_type='BioSQLRoot'
예제 #13
0
class IBioSQLDatabase(IBioSQLProxy):
    """ IReadContainer  """
    id = schema.TextLine(title=_(u"biodatabase_id"), required=True)
    # authority = schema.TextLine(title=_(u"authority"))
    description = schema.Text(title=_(u"description"))
예제 #14
0
            return []
    references = property(fget=getReferences)

    def getOrganism(self):
        if self.annotations.has_key('organism'):
            return self.annotations['organism']
        else:
            return ""
    organism = property(fget=getOrganism)

    def getAccessions(self):
        if self.annotations.has_key('accessions'):
            return self.annotations['accessions']
        else:
            return ""
    accessions = property(fget=getAccessions)

    def getTaxonomy(self):
        if self.annotations.has_key('taxonomy'):
            return self.annotations['taxonomy']
        else:
            return []
    taxonomy = property(fget=getTaxonomy)

    def alphabetClass(self):
        return self.seqrecord.seq.alphabet.__class__

InitializeClass(BioSQLSeqRecord)

bioSQLSeqRecordFactory = Factory(BioSQLSeqRecord, title=_(u"Create a new BioSQL SeqRecord"))