Exemple #1
0
    def _test_HTMLfile(self):
        """
        Create two html files (project and molecule) that have relative links to each other.
        Exercising the machinery in HTMLfile class.
        """
        entryId = "test_HTMLfile"

        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        project.appendMolecule(molecule)
        # initialize project html page
        # per item always set 2 top level attributes:
        project.htmlLocation = (project.path('index.html'), None)
        project.html = HTMLfile(project.htmlLocation[0],
                                project,
                                title='Project')
        nTdebug("project.htmlLocation[0]: %s" % project.htmlLocation[0])
        #create new folders for Molecule/HTML
        htmlPath = project.htmlPath()
        if os.path.exists(htmlPath):
            removedir(htmlPath)
        os.makedirs(htmlPath)
        nTdebug("htmlPath: %s" % htmlPath)

        # initialize molecule html page
        for subdir in htmlDirectories.values():
            project.mkdir(project.molecule.name, moleculeDirectories.html,
                          subdir)

        # NB project.htmlPath is different from project.path
        molecule.htmlLocation = (project.htmlPath('indexMolecule.html'), None)
        nTdebug("molecule.htmlLocation[0]: %s" % molecule.htmlLocation[0])
        molecule.html = HTMLfile(molecule.htmlLocation[0],
                                 project,
                                 title='Molecule ' + molecule.name)

        # nb: destination is a destination obj (eg molecule object) that is to
        # have a html attribute that points to an HTMLfile instance.
        # In the validate.py code, the source argument is the 'main' section in
        # project.html. JFD doesn't understand why.
        project.html.insertHtmlLinkInTag('li',
                                         section=project.html.main,
                                         source=project,
                                         destination=molecule,
                                         text='mol ref',
                                         id=None)
        # rerun for testing.
        _link = project.html.findHtmlLocation(project, molecule, id=None)
        #        self.assertEquals('moleculeName/HTML/indexMolecule.html#_top', link)
        project.html.main('ul', openTag=False)

        for htmlObj in [project.html, molecule.html]:
            self.assertFalse(htmlObj.render())
Exemple #2
0
    def testROGscore(self):
        entryId = 'test'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        molecule.ensemble = Ensemble(molecule)  # Needed for html.
        project.appendMolecule(molecule)  # Needed for html.

        # Add some crud to prevent warnings/errors later.
        molecule.addChain('top')
        top = molecule.allChains()[0]
        # Disable warnings temporarily
        v = cing.verbosity
        cing.verbosity = verbosityNothing
        for i in range(1 * 10):
            res = top.addResidue(repr(random()), i)
            for j in range(5):
                _atom = res.addAtom(repr(random()), j)
        cing.verbosity = v

        molecule.updateAll()
        project.setupHtml()  # Needed for creating the sub dirs.

        a = Atom(resName='ALA', atomName='HN')
        a.criticize()
        self.assertTrue(a)
        self.assertEquals(a.rogScore.colorLabel, COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][0], COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][1],
                          ROGscore.ROG_COMMENT_NO_COOR)
        lotr_remark = 'One ring to rule them all'
        preserved_remark = 'Preserved'
        nowHasEffect_remark = 'Now has effect'
        nowHasEffectToo_remark = 'Now has effect too'
        # Next line will have to wipe out the orange comments.
        a.rogScore.setMaxColor(COLOR_RED, lotr_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffect_remark)
        a.rogScore.setMaxColor(COLOR_RED, preserved_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffectToo_remark)
        self.assertEquals(len(a.rogScore.colorCommentList), 5)
        self.assertEquals(a.rogScore.colorCommentList[0][1],
                          ROGscore.ROG_COMMENT_NO_COOR)
        self.assertEquals(a.rogScore.colorCommentList[1][1],
                          nowHasEffect_remark)

        myhtml = HTMLfile('testROGscore.html', project, 'A Test')
        myhtml.main("a main")
        a.rogScore.createHtmlForComments(myhtml.main)

        kw = {}
        a.rogScore.addHTMLkeywords(kw)
        myhtml.main("a", 'or by popup', **kw)
        myhtml.render()
Exemple #3
0
    def testMakeHtmlTableWithJS(self):
        #        CSS and Javascript is going to determine much of the formatting.
        project = self.setupSimplestProject()
        h = HTMLfile(project.htmlPath('test.html'), project)
        columnFormats = [('col1', {}), ('col2', {}), ('col3', {})]

        t = MakeHtmlTable(h.main,
                          showHeader=False,
                          classId="testJsTable",
                          id="testJsTableId",
                          columnFormats=columnFormats,
                          bla="0")
        for row in t.rows(range(2)):
            rStr = str(row)
            t.nextColumn()
            t(None, rStr)
            t.nextColumn()
            t('a', rStr + "." + str(2), href='someRefHere')
            t.nextColumn()  # empty one
            t.nextColumn()
            t(None, rStr + "." + str(4))

        #end for
        h.main('h3', 'Text to start below the table.')
        h.render()
Exemple #4
0
    def testROGscore(self):
        entryId = 'test'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        molecule.ensemble = Ensemble(molecule) # Needed for html.
        project.appendMolecule(molecule) # Needed for html.

        # Add some crud to prevent warnings/errors later.
        molecule.addChain('top')
        top = molecule.allChains()[0]
        # Disable warnings temporarily
        v = cing.verbosity
        cing.verbosity = verbosityNothing
        for i in range( 1*10):
            res = top.addResidue( repr(random()),i )
            for j in range( 5):
                _atom = res.addAtom( repr(random()),j )
        cing.verbosity = v


        molecule.updateAll()
        project.setupHtml() # Needed for creating the sub dirs.

        a = Atom(resName='ALA', atomName='HN')
        a.criticize()
        self.assertTrue(a)
        self.assertEquals(a.rogScore.colorLabel, COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][0], COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][1], ROGscore.ROG_COMMENT_NO_COOR)
        lotr_remark = 'One ring to rule them all'
        preserved_remark = 'Preserved'
        nowHasEffect_remark = 'Now has effect'
        nowHasEffectToo_remark = 'Now has effect too'
        # Next line will have to wipe out the orange comments.
        a.rogScore.setMaxColor(COLOR_RED, lotr_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffect_remark )
        a.rogScore.setMaxColor(COLOR_RED, preserved_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffectToo_remark)
        self.assertEquals(len(a.rogScore.colorCommentList), 5)
        self.assertEquals(a.rogScore.colorCommentList[0][1], ROGscore.ROG_COMMENT_NO_COOR)
        self.assertEquals(a.rogScore.colorCommentList[1][1], nowHasEffect_remark)

        myhtml = HTMLfile('testROGscore.html', project, 'A Test')
        myhtml.main("a main")
        a.rogScore.createHtmlForComments(myhtml.main)

        kw = {}
        a.rogScore.addHTMLkeywords(kw)
        myhtml.main("a", 'or by popup', **kw)
        myhtml.render()
Exemple #5
0
    def testMakeHtmlTableWithJS(self):
#        CSS and Javascript is going to determine much of the formatting.
        project = self.setupSimplestProject()
        h = HTMLfile(project.htmlPath('test.html'), project)
        columnFormats = [ ('col1', {}),
                          ('col2', {}),
                          ('col3', {})
                                 ]

        t = MakeHtmlTable(h.main, showHeader=False, classId="testJsTable", id="testJsTableId", columnFormats=columnFormats,
                          bla="0")
        for row in t.rows(range(2)):
            rStr = str(row)
            t.nextColumn()
            t(None, rStr)
            t.nextColumn()
            t('a', rStr + "." + str(2), href='someRefHere')
            t.nextColumn()  # empty one
            t.nextColumn()
            t(None, rStr + "." + str(4))

        #end for
        h.main('h3', 'Text to start below the table.')
        h.render()
Exemple #6
0
    def test_HTMLfile_simple(self):
        project = self.setupSimplestProject()

        myhtml = HTMLfile('myTest.html', project, 'A Test')
        myhtml.header("a header")
        myhtml('h1', 'It is a test')
        myhtml.main("a main")
        myhtml.openTag('a', href="http://www.apple.com")
        myhtml('img', src='apple1.jpg')
        myhtml.closeTag('a')
        myhtml('a', 'testing link', href="http://www.bioc.cam.ac.uk/")
        myhtml.render()

        ###############
        myhtml = HTMLfile('myTest2.html', project, 'A Test 2')

        myhtml.header('h1', 'It is a test 2')
        myhtml.header('h2', 'another line')

        myhtml.main('a', href="http://www.apple.com", closeTag=False)
        myhtml.main('img', src='apple1.jpg')
        myhtml.main('a', openTag=False)
        myhtml.main('a', 'testing link', href="http://www.bioc.cam.ac.uk/")

        myhtml('br', 'used call')

        myhtml.render()
Exemple #7
0
    def test_HTMLfile_simple(self):
        project = self.setupSimplestProject()

        myhtml = HTMLfile('myTest.html', project, 'A Test')
        myhtml.header("a header")
        myhtml('h1', 'It is a test')
        myhtml.main("a main")
        myhtml.openTag('a', href="http://www.apple.com")
        myhtml('img', src = 'apple1.jpg')
        myhtml.closeTag('a')
        myhtml('a', 'testing link', href="http://www.bioc.cam.ac.uk/")
        myhtml.render()

    ###############
        myhtml = HTMLfile('myTest2.html', project, 'A Test 2')

        myhtml.header('h1', 'It is a test 2')
        myhtml.header('h2', 'another line')

        myhtml.main('a', href="http://www.apple.com", closeTag=False)
        myhtml.main('img', src = 'apple1.jpg')
        myhtml.main('a', openTag=False)
        myhtml.main('a', 'testing link', href="http://www.bioc.cam.ac.uk/")

        myhtml('br', 'used call')

        myhtml.render()