Exemple #1
0
def updateTag(request):
    # read in the crucial parameters
    tagKey = request.PUT.get('id', None)
    if not tagKey:
        raise Errors.MISSING_PARAMETER.setCustom('id')
    
    points = request.PUT.get('points', None)
    if points:
        try:
            points = json.loads(points)
        except ValueError:
            raise Errors.INVALID_SYNTAX.setCustom('points')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('points')
    
    color = request.PUT.get('color', None)
    if color:
        try:
            color = json.loads(color)
        except ValueError:
            color = Util.getDelimitedList(request.PUT, 'color')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('color')
    
    name = request.PUT.get('name', None)
    if not name:
        raise Errors.MISSING_PARAMETER.setCustom('name')
    
    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.PUT, 'fields')
    putAPI = PutAPI(request.user, fields)
    
    return putAPI.updateTag(tagKey, points, name, color)
Exemple #2
0
def getImageTags(request):
    renderObj = WebServiceObject()
    
    # read in crucial parameters
    tagGroupKey = request.GET.get('tagGroupId', None)
    imageKey = request.GET.get('imageId', None)
    
    # read in optional parameters and initialize the API
    offset = Util.getInt(request.GET, 'offset', 0)
    limit = Util.getInt(request.GET, 'limit', 10)
    unlimited = request.GET.get('unlimited', False)
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(limit, offset, request.user, fields, unlimited)
    
    if tagGroupKey:
        # the key for lookup and the image it is attached to
        renderObj = getAPI.getTagsByTagGroup(tagGroupKey, isKey=True)
    elif imageKey:
        # the key for lookup and the image it is attached to
        renderObj = getAPI.getTagsByImage(imageKey, isKey=True)
    else:
        # get all the tags
        renderObj = getAPI.getTags()
           
    return renderObj
Exemple #3
0
def updateTag(request):
    # read in the crucial parameters
    tagKey = request.PUT.get('id', None)
    if not tagKey:
        raise Errors.MISSING_PARAMETER.setCustom('id')

    points = request.PUT.get('points', None)
    if points:
        try:
            points = json.loads(points)
        except ValueError:
            raise Errors.INVALID_SYNTAX.setCustom('points')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('points')

    color = request.PUT.get('color', None)
    if color:
        try:
            color = json.loads(color)
        except ValueError:
            color = Util.getDelimitedList(request.PUT, 'color')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('color')

    name = request.PUT.get('name', None)
    if not name:
        raise Errors.MISSING_PARAMETER.setCustom('name')

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.PUT, 'fields')
    putAPI = PutAPI(request.user, fields)

    return putAPI.updateTag(tagKey, points, name, color)
Exemple #4
0
def getImageTags(request):
    renderObj = WebServiceObject()

    # read in crucial parameters
    tagGroupKey = request.GET.get('tagGroupId', None)
    imageKey = request.GET.get('imageId', None)

    # read in optional parameters and initialize the API
    offset = Util.getInt(request.GET, 'offset', 0)
    limit = Util.getInt(request.GET, 'limit', 10)
    unlimited = request.GET.get('unlimited', False)
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(limit, offset, request.user, fields, unlimited)

    if tagGroupKey:
        # the key for lookup and the image it is attached to
        renderObj = getAPI.getTagsByTagGroup(tagGroupKey, isKey=True)
    elif imageKey:
        # the key for lookup and the image it is attached to
        renderObj = getAPI.getTagsByImage(imageKey, isKey=True)
    else:
        # get all the tags
        renderObj = getAPI.getTags()

    return renderObj
    def doProcessRender(self, request):
        self.addPageletBinding('navBar', NavBarPagelet())

        numSearch = 0
        searchImageDesc = str(request.GET.get('searchImageDesc',
                                              '')).lower() == "true"
        searchImageNotes = str(request.GET.get('searchImageNotes',
                                               '')).lower() == "true"
        searchGeneName = str(request.GET.get('searchGeneName',
                                             '')).lower() == "true"
        searchGeneSymbol = str(request.GET.get('searchGeneSymbol',
                                               '')).lower() == "true"
        searchGeneID = str(request.GET.get('searchGeneID',
                                           '')).lower() == "true"
        query = Util.getDelimitedList(request.GET, 'query')

        #print searchImageDesc
        #print searchImageNotes
        #print searchGeneName
        #print searchGeneSymbol
        #print searchGeneID

        candidate_cat = []

        if searchImageDesc:
            query = Util.getDelimitedList(request.GET, 'query')
            print query
            print len(query)
            candidates_ImgDesc = []
            candidate_cat.append('Image Description')

            if query:
                pictures = Picture.objects.filter(
                    description__icontains=query[0])
                print pictures
                candidates_ImgDesc.append(pictures)

            formatQuery = ""
            if query:
                formatQuery += 'General Query: "' + ", ".join(query) + '"'

        search = {
            'candidate_cat': candidate_cat,
            'candidates_ImgDesc': candidates_ImgDesc,
            'query': formatQuery
        }

        #if searchImageDesc:
        numSearch += 1
        self.addPageletBinding('center-' + str(numSearch),
                               ImageSearchPagelet().setSearchParams(search))

        args = {'title': 'Search', 'numPagelets': numSearch}
        self.setApplicationLayout('public/search.html', args)

        self.addPageletBinding('footer', FooterPagelet())
Exemple #6
0
def getOrganisms(request):
    # get the list of organisms (base on comma delimited list)
    organisms = Util.getDelimitedList(request.GET, 'organisms')

    # optional parameters
    fields = Util.getDelimitedList(request.GET, 'fields')

    getAPI = GetAPI(request.user, fields)

    return getAPI.getOrganisms(organisms)
Exemple #7
0
def getOrganisms(request):
    # get the list of organisms (base on comma delimited list)
    organisms = Util.getDelimitedList(request.GET, 'organisms')
    
    # optional parameters
    fields = Util.getDelimitedList(request.GET, 'fields')

    getAPI = GetAPI(request.user, fields)
    
    return getAPI.getOrganisms(organisms)
Exemple #8
0
def getImageTagGroups(request):
    # the key for lookup and the image it is attached to
    imageKey = request.GET.get('imageId', None)
    offset = Util.getInt(request.GET, 'offset', 0)
    limit = Util.getInt(request.GET, 'limit', 10)

    unlimited = request.GET.get('unlimited', False)
    fields = Util.getDelimitedList(request.GET, 'fields')
    
    getAPI = GetAPI(limit, offset, request.user, fields, unlimited)
    
    if imageKey:
        return getAPI.getTagGroupsByImage(imageKey)
    else:
        return getAPI.getTagGroups()
Exemple #9
0
def createImageMetadata(request):
    renderObj = WebServiceObject()
    
    # these should overwrite current metadata
    image = request.FILES.get('image', None)
    description = request.POST.get('description', None)
    altText = request.POST.get('altText', None)
    organisms = Util.getDelimitedList(request.POST, 'organisms')
    fields = Util.getDelimitedList(request.POST, 'fields')
    
    if image:
        postAPI = PostAPI(request.user, fields)
        renderObj = postAPI.createImageMetadata(image, description, altText, organisms)
    else:
        raise Errors.MISSING_PARAMETER.setCustom('image')
    
    return renderObj
Exemple #10
0
def getQtl(request):
    imageKey = request.GET.get('pictureID', None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(request.user, fields)

    return getAPI.getQtl(imageKey)
Exemple #11
0
def createImageMetadata(request):
    renderObj = WebServiceObject()

    # these should overwrite current metadata
    image = request.FILES.get('image', None)
    description = request.POST.get('description', None)
    altText = request.POST.get('altText', None)
    organisms = Util.getDelimitedList(request.POST, 'organisms')
    fields = Util.getDelimitedList(request.POST, 'fields')

    if image:
        postAPI = PostAPI(request.user, fields)
        renderObj = postAPI.createImageMetadata(image, description, altText,
                                                organisms)
    else:
        raise Errors.MISSING_PARAMETER.setCustom('image')

    return renderObj
Exemple #12
0
def getImageMetadata(request):
    #optional parameters
    offset = Util.getInt(request.GET, 'offset', 0)
    limit = Util.getInt(request.GET, 'limit', 10)
    unlimited = request.GET.get('unlimited', False)
    fields = Util.getDelimitedList(request.GET, 'fields')

    getAPI = GetAPI(limit, offset, request.user, fields, unlimited)
    if request.GET.has_key('by'):
        by = request.GET['by']        
        if by == 'organism':
            # required paramaters
            organismIds = Util.getDelimitedList(request.GET, 'organismId')
            return getAPI.getImageMetadataByOrganism(organismIds)
        else:
            raise Errors.INVALID_PARAMETER.setCustom('by')
    else:
        return getAPI.getImageMetadata()
Exemple #13
0
def deleteImage(request):
    # required parameters
    imageKey = request.DELETE.get('id', None)
    if not imageKey:
        raise Errors.NO_IMAGE_KEY

    fields = Util.getDelimitedList(request.GET, 'fields')

    deleteAPI = DeleteAPI(request.user, fields)
    return deleteAPI.deleteImage(imageKey)
Exemple #14
0
def deleteImage(request):
    # required parameters
    imageKey = request.DELETE.get('id', None)
    if not imageKey:
        raise Errors.NO_IMAGE_KEY
    
    fields = Util.getDelimitedList(request.GET, 'fields')
    
    deleteAPI = DeleteAPI(request.user, fields)
    return deleteAPI.deleteImage(imageKey)
Exemple #15
0
def deleteTagGroup(request):
    tagGroupKey = request.DELETE.get('id', None)

    if not tagGroupKey:
        raise Errors.MISSING_PARAMETER.setCustom('id')

    # get optional parameter
    fields = Util.getDelimitedList(request.DELETE, 'fields')

    deleteAPI = DeleteAPI(request.user, fields)
    return deleteAPI.deleteTagGroup(tagGroupKey)
Exemple #16
0
def deleteTagGroup(request):
    tagGroupKey = request.DELETE.get("id", None)

    if not tagGroupKey:
        raise Errors.MISSING_PARAMETER.setCustom("id")

    # get optional parameter
    fields = Util.getDelimitedList(request.DELETE, "fields")

    deleteAPI = DeleteAPI(request.user, fields)
    return deleteAPI.deleteTagGroup(tagGroupKey)
Exemple #17
0
def editImageMetadata(request):
    renderObj = WebServiceObject()
    
    # required parameters
    imageKey = request.PUT.get('id', None)
    if not imageKey:
        raise Errors.NO_IMAGE_KEY
    
    # these should overwrite current metadata
    description = request.PUT.get('description', None)
    altText = request.POST.get('altText', None)
    organisms = Util.getDelimitedList(request.PUT, 'organisms')
    fields = Util.getDelimitedList(request.PUT, 'fields')
    
    if description or organisms:
        putAPI = PutAPI(request.user, fields)
        renderObj = putAPI.editImageMetadata(imageKey, description, altText, organisms)
    else:
        raise Errors.NOT_MODIFIED
    
    return renderObj
Exemple #18
0
def editImageMetadata(request):
    renderObj = WebServiceObject()

    # required parameters
    imageKey = request.PUT.get('id', None)
    if not imageKey:
        raise Errors.NO_IMAGE_KEY

    # these should overwrite current metadata
    description = request.PUT.get('description', None)
    altText = request.POST.get('altText', None)
    organisms = Util.getDelimitedList(request.PUT, 'organisms')
    fields = Util.getDelimitedList(request.PUT, 'fields')

    if description or organisms:
        putAPI = PutAPI(request.user, fields)
        renderObj = putAPI.editImageMetadata(imageKey, description, altText,
                                             organisms)
    else:
        raise Errors.NOT_MODIFIED

    return renderObj
Exemple #19
0
def getGeneLink(request):
    # read in crucial parameters
    geneLinkKey = request.GET.get('id', None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(request.user, fields)

    if not geneLinkKey:
        raise Errors.NO_GENE_LINK_KEY

    # the key for lookup and the image it is attached to
    return getAPI.getGeneLink(geneLinkKey)
Exemple #20
0
def getGeneLink(request):
    # read in crucial parameters
    geneLinkKey = request.GET.get('id', None)
    
    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(request.user, fields)

    if not geneLinkKey:
        raise Errors.NO_GENE_LINK_KEY
    
    # the key for lookup and the image it is attached to
    return getAPI.getGeneLink(geneLinkKey)
Exemple #21
0
def getTagGroup(request):
    # read in crucial parameters
    tagGroupKey = request.GET.get('id', None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(request.user, fields)

    if not tagGroupKey:
        raise Errors.NO_TAG_GROUP_KEY

    # the key for lookup and the image it is attached to
    return getAPI.getTagGroup(tagGroupKey)
Exemple #22
0
def getTagGroup(request):
    # read in crucial parameters
    tagGroupKey = request.GET.get("id", None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.GET, "fields")
    getAPI = GetAPI(request.user, fields)

    if not tagGroupKey:
        raise Errors.NO_TAG_GROUP_KEY

    # the key for lookup and the image it is attached to
    return getAPI.getTagGroup(tagGroupKey)
Exemple #23
0
def addNote(request):
    # get new note information
    notes = request.POST.get('notes', None)
    pn_id = request.POST.get('pn_id', None)
    imageKey = request.POST.get('pictureID', None)

    if not imageKey:
        raise Errors.NO_IMAGE_KEY

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.POST, 'fields')

    postAPI = PostAPI(request.user, fields)
    return postAPI.addNote(notes, pn_id, imageKey)
Exemple #24
0
def deleteTag(request):
    geneLinkKey = request.DELETE.get('id', None)
    
    if not geneLinkKey:
        raise Errors.MISSING_PARAMETER.setCustom('id')
    
    # get optional parameter
    fields = Util.getDelimitedList(request.DELETE, 'fields')
    
    deleteAPI = DeleteAPI(request.user, fields)
    return deleteAPI.deleteGeneLink(geneLinkKey)
    
    
    
Exemple #25
0
def createTag(request):
    # get the tagGroupKey
    tagGroupKey = request.POST.get('tagGroupId', None)
    if not tagGroupKey:
        raise Errors.NO_TAG_GROUP_KEY

    # get the points
    points = request.POST.get('points', None)
    if points:
        try:
            points = json.loads(points)
        except ValueError:
            raise Errors.INVALID_SYNTAX.setCustom('points')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('points')

    # get the color
    color = request.POST.get('color', None)
    if color:
        try:
            color = json.loads(color)
        except ValueError:
            color = Util.getDelimitedList(request.PUT, 'color')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('color')

    # get the description
    name = request.POST.get('name', None)
    if not name:
        raise Errors.MISSING_PARAMETER.setCustom('name')

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.POST, 'fields')

    postAPI = PostAPI(request.user, fields)
    return postAPI.createTag(tagGroupKey, points, name, color)
Exemple #26
0
def createTag(request):
    # get the tagGroupKey
    tagGroupKey = request.POST.get('tagGroupId', None)
    if not tagGroupKey:
        raise Errors.NO_TAG_GROUP_KEY
    
    # get the points
    points = request.POST.get('points', None)
    if points:
        try:
            points = json.loads(points)
        except ValueError:
            raise Errors.INVALID_SYNTAX.setCustom('points')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('points')
    
    # get the color
    color = request.POST.get('color', None)
    if color:
        try:
            color = json.loads(color)
        except ValueError:
            color = Util.getDelimitedList(request.PUT, 'color')
    else:
        raise Errors.MISSING_PARAMETER.setCustom('color')
    
    # get the description
    name = request.POST.get('name', None)
    if not name:
        raise Errors.MISSING_PARAMETER.setCustom('name')
    
    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.POST, 'fields')
        
    postAPI = PostAPI(request.user, fields)
    return postAPI.createTag(tagGroupKey, points, name, color)
Exemple #27
0
def createTagGroup(request):
    imageKey = request.POST.get('imageId', None)
    if not imageKey:
        raise Errors.MISSING_PARAMETER.setCustom('imageId')

    # get the description
    name = request.POST.get('name', None)
    if not name:
        raise Errors.MISSING_PARAMETER.setCustom('name')

    # get optional parameter
    fields = Util.getDelimitedList(request.POST, 'fields')

    postAPI = PostAPI(request.user, fields)
    return postAPI.createTagGroup(imageKey, name)
Exemple #28
0
def createTagGroup(request):
    imageKey = request.POST.get("imageId", None)
    if not imageKey:
        raise Errors.MISSING_PARAMETER.setCustom("imageId")

    # get the description
    name = request.POST.get("name", None)
    if not name:
        raise Errors.MISSING_PARAMETER.setCustom("name")

    # get optional parameter
    fields = Util.getDelimitedList(request.POST, "fields")

    postAPI = PostAPI(request.user, fields)
    return postAPI.createTagGroup(imageKey, name)
Exemple #29
0
def getImageMetadata(request):
    renderObj = WebServiceObject()
    if request.GET.has_key('id'):
        # the key for lookup and the image it is attached to
        imageKey = request.GET['id']
        fields = Util.getDelimitedList(request.GET, 'fields')
        getAPI = GetAPI(request.user, fields)
        try:
            renderObj = getAPI.getImageMetadata(imageKey)
        except Errors.WebServiceException as e:
            renderObj.setError(e)
    else:
        renderObj.setError(Errors.NO_IMAGE_KEY)

    return renderObj
Exemple #30
0
def getImageMetadata(request):
    renderObj = WebServiceObject()
    if request.GET.has_key('id'):
        # the key for lookup and the image it is attached to
        imageKey = request.GET['id']
        fields = Util.getDelimitedList(request.GET, 'fields')
        getAPI = GetAPI(request.user, fields)
        try:
            renderObj = getAPI.getImageMetadata(imageKey)
        except Errors.WebServiceException as e:
            renderObj.setError(e)
    else:
        renderObj.setError(Errors.NO_IMAGE_KEY)
    
    return renderObj
Exemple #31
0
def addQtl(request):
    # get new note information
    qtl = request.POST.get('qtl', None)
    pq_id = request.POST.get('pq_id', None)
    imageKey = request.POST.get('pictureID', None)

    print 'test addQql()'

    if not imageKey:
        raise Errors.NO_IMAGE_KEY

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.POST, 'fields')

    postAPI = PostAPI(request.user, fields)
    return postAPI.addQtl(qtl, pq_id, imageKey)
Exemple #32
0
def updateTagGroup(request):
    # read in the crucial parameters
    tagGroupKey = request.PUT.get('id', None)
    if not tagGroupKey:
        raise Errors.MISSING_PARAMETER.setCustom('id')

    name = request.PUT.get('name', None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.PUT, 'fields')
    putAPI = PutAPI(request.user, fields)

    if not name:
        raise Errors.NOT_MODIFIED

    return putAPI.updateTagGroup(tagGroupKey, name)
Exemple #33
0
def updateTagGroup(request):
    # read in the crucial parameters
    tagGroupKey = request.PUT.get("id", None)
    if not tagGroupKey:
        raise Errors.MISSING_PARAMETER.setCustom("id")

    name = request.PUT.get("name", None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.PUT, "fields")
    putAPI = PutAPI(request.user, fields)

    if not name:
        raise Errors.NOT_MODIFIED

    return putAPI.updateTagGroup(tagGroupKey, name)
Exemple #34
0
def getTag(request):
    # read in crucial parameters
    tagKey = request.GET.get('id', None)
    
    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.GET, 'fields')
    getAPI = GetAPI(request.user, fields)

    #TEST for debugging - logger
    logger = logging.getLogger(__name__)
    logger.error('logger test - ktcho')
    
    if not tagKey:
        raise Errors.NO_TAG_KEY

    # the key for lookup and the image it is attached to
    return getAPI.getTag(tagKey)
Exemple #35
0
def createGeneLink(request):
    # get tagId for new gene link
    tagId = request.POST.get('tagId', None)

    if not tagId:
        raise Errors.NO_TAG_KEY

    name = request.POST.get('name', None)
    allele = request.POST.get('allele', None)
    organismId = request.POST.get('organismId', None)

    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.POST, 'fields')

    if not (allele or (name and organismId)):
        if not allele:
            raise Errors.MISSING_PARAMETER.setCustom('allele')
        else:
            raise Errors.INVALID_SYNTAX.setCustom(
                'name and organismId required as a pair')

    postAPI = PostAPI(request.user, fields)
    return postAPI.createGeneLink(tagId, name, allele, organismId)
Exemple #36
0
def createGeneLink(request):
    # get tagId for new gene link
    tagId = request.POST.get('tagId', None)
    
    if not tagId:
        raise Errors.NO_TAG_KEY
    
    # find name or uniquename
    name = request.POST.get('name', None)
    uniquename = request.POST.get('uniqueName', None)
    organismId = request.POST.get('organismId', None)
    
    # read in optional parameters and initialize the API
    fields = Util.getDelimitedList(request.POST, 'fields')
    
    if not (uniquename or (name and organismId)):
        if not uniquename:
            raise Errors.MISSING_PARAMETER.setCustom('uniquename')
        else:
            raise Errors.INVALID_SYNTAX.setCustom('name and organismId required as a pair')
        
    postAPI = PostAPI(request.user, fields)
    return postAPI.createGeneLink(tagId, name, uniquename, organismId)
Exemple #37
0
    def doProcessRender(self, request):
        self.addPageletBinding('navBar', NavBarPagelet(addHelpButton=True))

        numSearch = 0
        searchCats = list('00000')
        searchImageDesc = str(request.GET.get('searchImageDesc',
                                              '')).lower() == "true"
        searchImageNotes = str(request.GET.get('searchImageNotes',
                                               '')).lower() == "true"
        searchGeneName = str(request.GET.get('searchGeneName',
                                             '')).lower() == "true"
        searchGeneSymbol = str(request.GET.get('searchGeneSymbol',
                                               '')).lower() == "true"
        searchGeneID = str(request.GET.get('searchGeneID',
                                           '')).lower() == "true"
        query = Util.getDelimitedList(request.GET, 'query')
        if not query:
            query = list()
            query.append('')

        #candidates = [['Image Description'], ['Image Notes'], ['Gene Name'], ['Gene Symbol'], ['Gene ID']]
        candidates = [['0'], ['1'], ['2'], ['3'], ['4']]

        if searchImageDesc:
            candidates[0][0] = 'Image Description'
            searchCats[0] = '1'
            pictures = Picture.objects.filter(description__icontains=query[0])
            for picture in pictures:
                candidates[0].append(picture)

        if searchImageNotes:
            candidates[1][0] = 'Image Notes'
            searchCats[1] = '1'
            pNotes = PictureNotes.objects.filter(notes__icontains=query[0])
            pictureIDs = []
            for note in pNotes:
                pictureID = note.picture.pk
                if not pictureID in pictureIDs:
                    pictureIDs.append(pictureID)
                    candidates[1].append(pictureID)

        if searchGeneName:
            candidates[2][0] = 'Gene Name'
            searchCats[2] = '1'
            pictureIDs = []
            pMgdbs = PictureMgdb.objects.filter(
                locus_full_name__icontains=query[0])
            for pMgdb in pMgdbs:
                pictureID = pMgdb.picture.pk
                if not pictureID in pictureIDs:
                    pictureIDs.append(pictureID)
                    candidates[2].append(pictureID)

        if searchGeneSymbol:
            candidates[3][0] = 'Gene Symbol'
            searchCats[3] = '1'
            pictureIDs = []
            pMgdbs = PictureMgdb.objects.filter(locus_name__icontains=query[0])
            for pMgdb in pMgdbs:
                pictureID = pMgdb.picture.pk
                if not pictureID in pictureIDs:
                    pictureIDs.append(pictureID)
                    candidates[3].append(pictureID)

        if searchGeneID:
            candidates[4][0] = 'Gene ID'
            searchCats[4] = '1'
            pictureIDs = []
            pIDs = PictureGeneID.objects.filter(gene_id__icontains=query[0])
            for pID in pIDs:
                pictureID = pID.picture.pk
                if pictureID not in pictureIDs:
                    pictureIDs.append(pictureID)
                    candidates[4].append(pictureID)

        # Store searching keyword
        if str(request.user) != 'AnonymousUser':
            catSettings = ''.join(searchCats)
            newKeyword, created = iSearchHistory.objects.get_or_create(
                keyword=query[0], user=request.user)
            if created:
                updateKeyword = iSearchHistory.objects.get(
                    pk__exact=newKeyword.pk)
                updateKeyword.catSettings = catSettings
                updateKeyword.save()
            else:
                newKeyword.catSettings = catSettings
                newKeyword.save()

        formatQuery = ""
        if query:
            formatQuery += 'General Query: "' + ", ".join(query) + '"'

        search = {'candidates': candidates, 'query': query[0]}

        numSearch += 1
        self.addPageletBinding('center-' + str(numSearch),
                               iSearchPagelet().setSearchParams(search))

        args = {'title': 'Image search', 'numPagelets': numSearch}
        self.setApplicationLayout('public/iSearch.html', args)

        self.addPageletBinding('footer', FooterPagelet())
Exemple #38
0
	def doProcessRender(self, request):
		self.addPageletBinding('navBar', NavBarPagelet())
		
		numSearch = 0
		searchImages = str(request.GET.get('searchImages', '')).lower() == "true"
		searchGenomes = str(request.GET.get('searchGenomes', '')).lower() == "true"
		
		if searchImages or searchGenomes:
			query = Util.getDelimitedList(request.GET,'query')
			organismId = Util.getDelimitedList(request.GET, 'organismId')
			candidates = []
			
			if organismId:
				organisms = Organism.objects.filter(pk__in=organismId)
				candidates.append(organisms)
			if query:
				for subquery in query:
					splitQuery = subquery.strip().split(' ')
					
					if (len(splitQuery) == 1):
						if organismId:
							candidate = Organism.objects.filter(species=splitQuery[0]).exclude(organism_id__in=organismId)
						else:
							candidate = Organism.objects.filter(species=splitQuery[0])
						candidates.append(candidate)
					elif(len(splitQuery) == 2):
						if organismId:
							candidate = Organism.objects.filter(Q(species=splitQuery[1]) & Q(genus=splitQuery[0])).exclude(organism_id__in=organismId)
						else:
							candidate = Organism.objects.filter(Q(species=splitQuery[1]) & Q(genus=splitQuery[0]))
						candidates.append(candidate)
					else:
						if organismId:
							candidate = Organism.objects.filter(common_name=subquery).exclude(organism_id__in=organismId)
						else:
							candidate = Organism.objects.filter(common_name=subquery)
						candidates.append(candidate)
			
			formatQuery = ""
			if query:
				formatQuery += 'General Query: "' + ", ".join(query) + '"'
			if organismId:
				amp = " & " if query else ""
				formatQuery += amp + 'Organism Id Query: "' + ", ".join(organismId) + '"'
			
			search = {
				'candidates' : candidates,
				'query' : formatQuery
			}
			
			if searchImages:
				numSearch += 1
				self.addPageletBinding('center-' + str(numSearch), ImageSearchPagelet().setSearchParams(search))
			
			if searchGenomes:
				numSearch += 1
				self.addPageletBinding('center-' + str(numSearch), GBrowseSearchPagelet().setSearchParams(search))
		
		args = {
			'title' : 'Search',
			'numPagelets' : numSearch
		}
		self.setApplicationLayout('public/search.html', args)
		
		self.addPageletBinding('footer', FooterPagelet())