コード例 #1
0
 def getToolDescription(cls):
     '''
     Specifies a help text in HTML that is displayed below the tool.
     '''
     from proto.hyperbrowser.HtmlCore import HtmlCore
     core = HtmlCore()
     core.descriptionLine('R-code', cls._exampleText(cls.rCode))
     return str(core)
コード例 #2
0
 def protoBinSpecHelpTextForUserBinSource(cls):
     core = HtmlCore()
     core.emphasize(
         'Allowed values: comma separated list of Ensembl gene ids. '
         '"*" means all genes. Example: "ENSG00000208234, ENSG00000199674"')
     core.styleInfoBegin(styleClass='infomessagesmall')
     core.descriptionLine(
         'Note', 'all overlapping gene isoforms have been merged to form '
         '"supergenes" with positions from the start of the gene '
         'located most upstream, to the end of the gene located '
         'most downstream.')
     core.styleInfoEnd()
     return str(core)
コード例 #3
0
    def getToolDescription():
        '''
        Specifies a help text in HTML that is displayed below the tool.
        '''
        from proto.hyperbrowser.HtmlCore import HtmlCore
        core = HtmlCore()
        core.paragraph('''
This tool combines elements from two separate data sets into a single track where
the elements are denoted as case (target) or control, depending on their source.
This allows analyses of how other tracks preferentially interact with case
elements as opposed to control elements.''')
        core.divider()
        core.smallHeader('Shared regions')
        core.paragraph('''
This tool supports four ways of handling regions that are found in both case and
control tracks. These regions do not need to be full segments, as defined in the
input tracks; the tool also correctly handles shared parts of segments.''')
        core.descriptionLine('Shared regions should be removed', \
            'the shared regions are not returned, neither as case nor as control segments')
        core.descriptionLine('Shared regions should be returned as case regions', \
            'the shared regions are all denoted as case regions and returned')
        core.descriptionLine('Shared regions should be returned as control regions', \
            'the shared regions are all denoted as control regions and returned')
        core.descriptionLine('Shared regions should be returned as they are', \
            '''
the shared regions are not handled in any way, but denoted according to whether
they were found in the case or the control input track. Note that this may
result in case and control regions that overlap. The subsequent analysis may not
handle this correctly.''')
        return str(core)
コード例 #4
0
 def _appendChrArmNoteIfNeeded(self, core):
     if self._kwArgs.get('forHypothesisTest'):
         core2 = HtmlCore()
         core2.styleInfoBegin(styleClass='infomessagesmall')
         core2.descriptionLine(
             'Note', 'For hypothesis tests where the positions of elements '
             'are randomized, the centromeres and other regions '
             'where the elements are never found should be removed '
             'from the analysis regions. In this case, use the '
             'chromosome arms as analysis regions, define specific '
             'bounding regions for the tracks, or use custom '
             'analysis regions. If this is not done, the resulting '
             'p-values are generally better than what they should '
             'have been.')
         core2.styleInfoEnd()
         core.paragraph(str(core2))
コード例 #5
0
 def getToolDescription(cls):
     core = HtmlCore()
     core.paragraph(
         "This is a simple tool for preprocessing track files in the HyperBrowser track repository. "
         "Please select a track directory from the standarized tracks file tree. "
     )
     core.divider()
     core.descriptionLine(
         "Recursion",
         "Directories can be selected at any level. The preprocessor will recursively visit all "
         "sub-directories of the selected directory")
     core.descriptionLine(
         "Track file merge",
         "All track files within a directory will be merged together as one track (under the "
         "assumption that all files are of the same track type).")
     return str(core)
コード例 #6
0
    def helpTextForUserBinSource(self):
        core = HtmlCore()
        core.paragraph(
            str(HtmlCore().emphasize(
                'Use the bounding regions of the selected '
                'track(s), if defined. If more than one track '
                'is selected, the intersection of the bounding '
                'regions is used, i.e. where the bounding '
                'regions are overlapping.')))

        core2 = HtmlCore()
        core2.divBegin(divId='help_bounding_regions',
                       divClass='infomessagesmall help',
                       style='display: block;')
        core2.paragraph(
            'Bounding regions are the regions where a track is defined, e.g. where '
            'there theoretically may be data. This means that if there is no data in '
            'a bounding region, the absence of data is informative, i.e. that the lack '
            'of data is not just caused by not looking at the particular region. '
            'Hence, the bounding region for most tracks should be defined without '
            'for instance the centromeres. For tracks with no explicitly defined '
            'bounding regions, the bounding regions are implicitly defined as all '
            '(complete) chromosomes containing at least one track element.')
        core2.divEnd()
        core2.toggle('More information about bounding regions',
                     styleId='help_bounding_regions')
        core.paragraph(str(core2))

        core3 = HtmlCore()
        core3.styleInfoBegin(styleClass='infomessagesmall')
        core3.descriptionLine(
            'Note',
            'Intersecting bounding regions currently only supported for '
            'two tracks. If using a third track or an intensity track, '
            'only the bounding regions of the two first tracks are '
            'considered.')
        core3.styleInfoEnd()
        core.paragraph(str(core3))

        self._appendChrArmNoteIfNeeded(core)

        core.hideToggle(styleId='help_bounding_regions')
        return str(core)
    def getToolDescription(cls):
        '''
        Specifies a help text in HTML that is displayed below the tool.
        '''
        from proto.hyperbrowser.HtmlCore import HtmlCore

        core = HtmlCore()

        core.paragraph('This tool computes the proportions of overlap between the segments '
                       'of a query track against each track in a collection of reference tracks '
                       'described in a GSuite file. The overlap proportions are output in a '
                       'BED file with the query segments, where each query segment is partitioned '
                       'and colored according to the overlap with each reference track.')

        core.divider()
        core.paragraph('To carry out the analysis, please follow these steps:')
        core.orderedList(['Select a genome build. Both the query track and the reference tracks'
                          'need to use the same genome build.',
                          'Select a query track from the HyperBrowser repository',
                          'Select a reference track collection as a GSuite file from history',
                          'Every track from the GSuite file is represented by a separate color, '
                          'presented to the user in a table.',
                          'Click "Execute"'])

        core.divider()
        core.paragraph('The resulting BED file can be visualized in external genome browsers. '
                       'To browse the segments, click the title of the resulting history element '
                       'and click "display at UCSC main". The UCSC Genome Browser will appear, '
                       'with the segments with color-coding imported as a track.')

        core.divider()
        core.smallHeader('Requirements for query track')
        core.descriptionLine('Track types', ', '.join(cls.TRACK_ALLOWED_TRACK_TYPES), emphasize=True)


        cls._addGSuiteFileDescription(core,
                                      allowedLocations=cls.GSUITE_ALLOWED_LOCATIONS,
                                      allowedFileFormats=cls.GSUITE_ALLOWED_FILE_FORMATS,
                                      allowedTrackTypes=cls.GSUITE_ALLOWED_TRACK_TYPES,
                                      disallowedGenomes=cls.GSUITE_DISALLOWED_GENOMES)

        return str(core)
コード例 #8
0
    def getToolDescription(cls):
        '''
        Specifies a help text in HTML that is displayed below the tool.
        '''
        from proto.hyperbrowser.HtmlCore import HtmlCore

        core = HtmlCore()

        core.paragraph('This tool computes the proportions of overlap between the segments '
                       'of a query track against each track in a collection of reference tracks '
                       'described in a GSuite file. The overlap proportions are output in an '
                       'interactive heatmap, where each cell is colored according to the '
                       'overlap between each query segment (column) with each reference '
                       'track (row).')

        core.divider()
        core.paragraph('To carry out the analysis, please follow these steps:')
        core.orderedList(['Select a genome build. Both the query track and the reference tracks'
                          'need to use the same genome build.',
                          'Select a query track from the HyperBrowser repository',
                          'Select a reference track collection as a GSuite file from history',
                          'Select the color map, going from no overlap to full overlap.',
                          'Click "Execute"'])

        core.divider()
        core.smallHeader('Requirements for query track')
        core.descriptionLine('Track types', ', '.join(cls.TRACK_ALLOWED_TRACK_TYPES), emphasize=True)


        cls._addGSuiteFileDescription(core,
                                      allowedLocations=cls.GSUITE_ALLOWED_LOCATIONS,
                                      allowedFileFormats=cls.GSUITE_ALLOWED_FILE_FORMATS,
                                      allowedTrackTypes=cls.GSUITE_ALLOWED_TRACK_TYPES,
                                      disallowedGenomes=cls.GSUITE_DISALLOWED_GENOMES)

        return str(core)
コード例 #9
0
    def getOptionsBoxHistoryElementsInfo(cls, prevChoices):
        if not prevChoices.dataType:
            return

        desc = prevChoices.subCategory

        core = HtmlCore()
        core.styleInfoBegin(styleClass='infomessagesmall')
        core.paragraph(
            'This tool will create seven history elements (one of which is hidden):'
        )
        descriptionList = \
            [('%s' % getGSuiteHistoryOutputName('storage', desc),
              'hidden history element containing the actual downloaded track data. Should '
              'in most cases be ignored'),
             ('%s' % getGSuiteHistoryOutputName('preprocessed', desc),
              'use this in the analysis tool of choice'),
             ('%s' % getGSuiteHistoryOutputName('nopreprocessed', desc),
              'preprocessing fails due to some issues with the track data. Some '
              'manipulation is probably needed before one tries preprocessing again'),
             ('%s' % getGSuiteHistoryOutputName('primary', desc),
              'use this if you need to manipulate the raw track data using a manipulation '
              'tool. The GSuite resulting from manipulation needs to be preprocessed '
              'before analysis'),
             ('%s' % getGSuiteHistoryOutputName('nodownload', desc),
              'in some cases the downloading of tracks fails, but might work if one tries again'),
             ('%s' % getGSuiteHistoryOutputName('remote', desc),
              'this refers to the original files available at a remote server. Use this '
              'if one for some reason needs to re-download all the tracks'),
             ('%s' % getGSuiteHistoryOutputName('progress', desc),
              'click the eye icon of this element to show the progress of the import')]
        for label, description in descriptionList:
            core.descriptionLine(label, description)
        core.styleInfoEnd()

        return '__rawstr__', unicode(core)
コード例 #10
0
    def mainInfo(self, printEmpty=False):
        core = HtmlCore()
        if printEmpty or self.species:
            core.descriptionLine(
                'Species',
                str(HtmlCore().link(self.species, self.speciesTaxonomyUrl)))
        if printEmpty or self.genomeBuildName:
            core.descriptionLine('Genome build', self.genomeBuildName + \
                                 (' (%s)' % self.genomeBuildSource if self.genomeBuildSource else ''))

        core.descriptionLine('Short name', self.genome)
        return str(core)
コード例 #11
0
    def allInfo(self, printEmpty=False):
        core = HtmlCore()

        if printEmpty or self.assemblyDetails:
            core.descriptionLine('Assembly details', self.assemblyDetails)

        if printEmpty or hasattr(self, 'numChrs') and self.numChrs:
            if hasattr(self, 'numExtChrs') and self.numExtChrs > 0:
                core.descriptionLine('Number of standard chromosomes',
                                     strWithStdFormatting(self.numChrs))
            else:
                core.descriptionLine('Number of chromosomes',
                                     strWithStdFormatting(self.numChrs))

        if printEmpty or hasattr(self, 'numExtChrs') and self.numExtChrs:
            core.descriptionLine('Number of extended chromosomes',
                                 strWithStdFormatting(self.numExtChrs))

        if printEmpty or hasattr(self, 'numBps') and self.numBps:
            if hasattr(self, 'numExtChrs') and self.numExtChrs > 0:
                core.descriptionLine(
                    'Total number of bps (standard chromosomes only)',
                    strWithStdFormatting(self.numBps))
            else:
                core.descriptionLine('Total number of bps',
                                     strWithStdFormatting(self.numBps))

        if printEmpty or hasattr(self, 'numBpsWithExt') and hasattr(
                self, 'numExtChrs') and self.numBpsWithExt and self.numExtChrs:
            core.descriptionLine(
                'Total number of bps (with extended chromosomes)',
                strWithStdFormatting(self.numBpsWithExt))

        return self.mainInfo(printEmpty) + str(core)
コード例 #12
0
    def getToolDescription():
        core = HtmlCore()
        core.paragraph(
            'This tool converts files between the following file formats:')
        core.descriptionLine('GTrack',
                             "See the 'Show GTrack specification' tool",
                             emphasize=True)
        core.descriptionLine('BED', str(HtmlCore().link('BED specification', \
                                        'http://genome.ucsc.edu/FAQ/FAQformat.html')), emphasize=True)
        core.descriptionLine('WIG', str(HtmlCore().link('WIG specification', \
                                        'http://genome.ucsc.edu/goldenPath/help/wiggle.html')), emphasize=True)
        core.descriptionLine('bedGraph', str(HtmlCore().link('bedGraph specification', \
                                            'http://genome.ucsc.edu/goldenPath/help/bedgraph.html')), emphasize=True)
        core.descriptionLine('GFF', str(HtmlCore().link('GFF version 3 specification', \
                                            'http://www.sequenceontology.org/gff3.shtml')), emphasize=True)
        core.descriptionLine('FASTA', str(HtmlCore().link('bedGraph specification', \
                                            'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')), emphasize=True)
        core.paragraph(
            'The input data type is defined by the format field of the history element of the data. '
            'The available conversions for the selected format are automatically '
            'shown in the conversion selection box')

        core.divider()

        core.smallHeader('Genome')
        core.paragraph(
            'Some GTrack files require a specified genome to be valid, e.g. if bounding regions '
            'are specified without explicit end coordinates.')

        core.divider()

        core.smallHeader('GTrack subtypes')
        core.paragraph(
            'If the conversion to extended GTrack is selected, GTrack subtype information may be '
            'added to the output file. The following GTrack subtypes are automatically detected from '
            'the contents of the input file:')

        from gold.origdata.GtrackComposer import StdGtrackComposer
        core.unorderedList(
            str(HtmlCore().link(x, x))
            for x in StdGtrackComposer.GTRACK_PRIORITIZED_SUBTYPE_LIST)
        core.divider()

        core.smallHeader('Notice')
        core.paragraph(
            "The GFF support is somewhat preliminary. For conversions between BED and GFF, we "
            "recommend the specialized Galaxy tools: 'BED-to-GFF converter' and 'GFF-to-BED converter'."
        )

        core.divider()

        core.smallHeader('Example 1')
        core.paragraph('Input file (BED)')
        core.styleInfoBegin(styleClass='debug')
        core.append(
            '''chrM    71      82      A       1000    +       71      79      0,0,255 2       4,4,    0,8
chrM    103     105     B       800     .       103     105     0,255,0 1       2       0
chr21   3       13      C       645     -       3       13      255,0,0 3       2,2,2   0,5,8'''
        )
        core.styleInfoEnd()

        core.paragraph('Output file (Extended GTrack)')
        core.styleInfoBegin(styleClass='debug')
        core.append('''##gtrack version: 1.0
##track type: valued segments
##uninterrupted data lines: true
###seqid	start	end	value	strand	name	thickstart	thickend	itemrgb	blockcount	blocksizes	blockstarts
chrM	71	82	1000	+	A	71	79	0,0,255	2	4,4,	0,8
chrM	103	105	800	.	B	103	105	0,255,0	1	2	0
chr21	3	13	645	-	C	3	13	255,0,0	3	2,2,2	0,5,8''')
        core.styleInfoEnd()

        core.divider()

        core.smallHeader('Example 2')
        core.paragraph('Input file (WIG)')
        core.styleInfoBegin(styleClass='debug')
        core.append('''track type=wiggle_0
fixedStep chrom=chrM start=11 step=10 span=5
4.500
-3.700
fixedStep chrom=chrM start=1013 step=10 span=5
2.100
11.00
fixedStep chrom=chr21 start=201 step=10 span=5
21.10''')
        core.styleInfoEnd()

        core.paragraph('Output file (bedGraph)')
        core.styleInfoBegin(styleClass='debug')
        core.append('''track type=bedGraph
chrM	10	15	4.500
chrM	20	25	-3.700
chrM	1012	1017	2.100
chrM	1022	1027	11.00
chr21	200	205	21.10''')
        core.styleInfoEnd()

        core.paragraph('Output file (GTrack)')
        core.styleInfoBegin(styleClass='debug')
        core.append('''##gtrack version: 1.0
##track type: valued segments
##1-indexed: true
##end inclusive: true
##fixed length: 5
##fixed gap size: 5
##gtrack subtype: wig fixedstep
##subtype url: http://gtrack.no/wig_fixedstep.gtrack
##subtype adherence: strict
###value
####seqid=chrM; start=11; end=25
4.5
-3.7
####seqid=chrM; start=1013; end=1027
2.1
11.0
####seqid=chr21; start=201; end=205
21.1''')
        core.styleInfoEnd()
        return str(core)
コード例 #13
0
    def getToolDescription():
        core = HtmlCore()
        core.paragraph('This tool is used to create GTrack files from any tabular input file. The '
                       'user must select the column names for the table, enabling the GTrack '
                       'header expander to automatically expand the headers, effectively converting '
                       'the file to a GTrack file. Custom column names are also supported.')
        core.divider()

        core.smallHeader('The following column names are part of the GTrack specification')
        core.descriptionLine('seqid', "An identifier of the underlying sequence of "
                                      "the track element (i.e. the row). Example: 'chr1'", emphasize=True)
        core.descriptionLine('start', 'The start position of the track element', emphasize=True)
        core.descriptionLine('end', 'The end position of the track element', emphasize=True)
        core.descriptionLine('value', 'A value associated to the track element. '
                                      'The value type is automatically found by the tool.', emphasize=True)
        core.descriptionLine('strand', "The strand of the track element, either '+', '-' or '.'", emphasize=True)
        core.descriptionLine('id', "An unique identifier of the track element, e.g. 'a'", emphasize=True)
        core.descriptionLine('edges', "A semicolon-separated list of id's, representing "
                                      "edges from this track element to other elements. "
                                      "Weights may also be specified. Example: 'a=1.0;b=0.9'", emphasize=True)
        core.paragraph("See the 'Show GTrack specification' tool for more information.")
        core.divider()

        core.smallHeader('Column selection method')
        core.paragraph('The tool supports two ways of selecting column names. First, you can select '
                       'the column names manually. The other option is to select a GTrack file in the '
                       'the history. The tool will then use the same column names (only using the first '
                       'columns if the number of columns in the current tabular file is less than in the '
                       'GTrack file.')
        core.divider()

        core.smallHeader('Genome')
        core.paragraph("Some GTrack files require a specified genome to be valid, e.g. if bounding regions "
                       "are specified without explicit end coordinates. A genome build must thus be selected if "
                       "such a GTrack file is to be used as template file for column specification. "
                       "Also, auto-correction of the sequence id ('seqid') column requires the selection of a "
                       "genome build. The resulting GTrack file in the history will be associated with the "
                       "selected genome.")
        core.divider()

        core.smallHeader('Track type')
        core.paragraph('According to the columns selected, the tool automatically finds the '
                       'corresponding track type according to the GTrack specification. '
                       'Note that dense track types are noe supported yet byt this tool.')
        core.divider()

        core.smallHeader('Indexing standard')
        core.paragraph('Two common standards of coordinate indexing are common in bioinformatics. A track '
                       'element covering the first 10 base pairs of chr1 are represented in two ways:' )
        core.descriptionLine('0-indexed, end exclusive', "seqid=chr1, start=0, end=10", emphasize=True)
        core.descriptionLine('1-indexed, end inclusive', "seqid=chr1, start=1, end=10", emphasize=True)
        core.paragraph('The GTrack format supports both standards, but the user must inform the system '
                       'which standard is used for each particular case.')
        core.divider()

        core.smallHeader('Auto-correction of sequence id')
        core.paragraph("The tool supports auto-correction of the sequence id ('seqid') column. "
                       "If this is selected, a search is carried out on the sequence id's defined "
                       "for the current genome build. The nearest match, if unique, is inserted in "
                       "the new GTrack file. If no unique match is found, the original value is "
                       "used. The algorithm also handles roman numbers. Example: 'IV' -> 'chr4'")
        core.divider()

        core.smallHeader('Example')
        core.paragraph('Input table')
        core.tableHeader(['start','','id','something','seqid'])
        core.tableLine(['100','.','a','yes','chr1'])
        core.tableLine(['250','.','b','yes','chr1'])
        core.tableLine(['120','.','c','no','chr2'])
        core.tableFooter()

        core.paragraph('Output file')
        core.styleInfoBegin(styleClass='debug')
        core.append(
'''##gtrack version: 1.0
##track type: points
##uninterrupted data lines: true
##sorted elements: true
##no overlapping elements: true
###seqid  start  id	 something
chr1	  100	 a	 yes
chr1	  250	 b	 yes
chr2	  120	 c	 no''')
        core.styleInfoEnd()

        return str(core)
コード例 #14
0
    def getToolDescription():
        core = HtmlCore()
        core.paragraph(
            'This tool is used to complement the data of a GTrack '
            'file with additional columns from another GTrack file. '
            'Note that all data lines of the first GTrack file is '
            'retained, but the contents of the second is only used if '
            'the tool finds a match.')
        core.divider()
        core.smallHeader('Genome')
        core.paragraph(
            'Some GTrack files require a specified genome to be valid, e.g. if bounding regions '
            'are specified without explicit end coordinates.')

        core.divider()
        core.smallHeader('Intersecting factor')
        core.paragraph('This choice governs how a the data lines of the two '
                       'GTrack files are matched.')
        core.descriptionLine('Element ID', 'the data lines are matched on the ' +\
                             str(HtmlCore().emphasize('id')) + ' column.', emphasize=True)
        core.descriptionLine('Positional information', \
                             'the matching is done using any of the ' + \
                             '%s, %s, %s, and %s columns ' % \
                             tuple(str(HtmlCore().emphasize(x)) for x in \
                              ['genome', 'seqid', 'start', 'end']) +\
                             'that are defined in both ' +\
                             'GTrack files. Note that the match must be complete, ' +\
                             'e.g. matching both start and end if both are ' +\
                             'defined for one of the GTrack files.', emphasize=True)
        core.divider()
        core.smallHeader('Example')
        core.paragraph('File 1:')

        core.styleInfoBegin(styleClass='debug')
        core.append('''##track type: valued segments
###seqid  start  end  value  id
chrM      100    120  2.5    A
chrM      200    220  1.2    B''')
        core.styleInfoEnd()

        core.paragraph('File 2:')

        core.styleInfoBegin(styleClass='debug')
        core.append('''##track type: points
###seqid  start  strand  sth  other  id
chrM      300    +       b    yes    B
chrM      400    -       c    yes    C
chrM      500    -       a    no     A''')
        core.styleInfoEnd()

        core.paragraph('Complementing on "Element ID" and choosing the ' +\
                        'additional columns %s and %s, gives:' % \
                        tuple(str(HtmlCore().emphasize(x)) for x in ('strand', 'other')))

        core.styleInfoBegin(styleClass='debug')
        core.append('''##gtrack version: 1.0
##track type: valued segments
##uninterrupted data lines: true
##sorted elements: true
##no overlapping elements: true
###seqid  start  end  value  strand  id  other
chrM      100    120  2.5    -       A   no
chrM      200    220  1.2    +       B   yes''')
        core.styleInfoEnd()

        return str(core)
コード例 #15
0
    def getRunDescription(genome, trackNames, analysisDef, ubSource,
                          revEngBatchLine, urlForTrackAutoSelection, **kwArgs):
        # genome = ubSource.genome
        assert len(trackNames) == 3
        core = HtmlCore()

        analysis = Analysis(analysisDef, genome, trackNames[0], trackNames[1],
                            **kwArgs)

        core.header('GENOME')
        core.append(GenomeInfo(genome).mainInfo(printEmpty=False))
        core.divider()

        formatChoices = analysis.getFormatConverterChoicesAsText().items()
        tr1FormatChoice, tr2FormatChoice = formatChoices if len(
            formatChoices) == 2 else (None, None)

        first = True
        for tn,label,formatChoice in zip(trackNames, \
                                         ['TRACK 1', 'TRACK 2', 'INTENSITY TRACK'], \
                                         [tr1FormatChoice, tr2FormatChoice, None]):
            if tn in [None, []]:
                continue

            if not first:
                core.divider()

            core.header(label)
            trackInfo = TrackInfo(genome, tn)
            trackText = ''
            if ExternalTrackManager.isHistoryTrack(tn):
                assert len(
                    tn) >= 4, 'Length of external track name < 4: %s' % str(tn)
                core.descriptionLine(
                    'Name',
                    ExternalTrackManager.extractNameFromHistoryTN(tn) +
                    ' (from history)' + os.linesep)
            else:
                core.descriptionLine('Name', ':'.join(tn) + os.linesep)
            core.append(trackInfo.mainInfo(printEmpty=False))

            if formatChoice is not None:
                core.descriptionLine('Treated as', formatChoice[1])

            first = False

        core.divider()
        core.header('ANALYSIS')
        core.paragraph(''.join(str(analysis).split(':')[1:]))

        first = True
        for label, choice in analysis.getInterfaceChoicesAsText().items():
            if first:
                core.divider()
                core.header('OPTIONS')

            core.descriptionLine(label, choice)
            first = False

        h0 = analysis.getH0()
        if h0 is not None:
            core.divider()
            core.header('NULL HYPOTHESIS')
            core.paragraph(h0)

        h1 = analysis.getH1()
        if h1 is not None:
            core.divider()
            core.header('ALTERNATIVE HYPOTHESIS')
            core.paragraph(h1)

        core.divider()
        core.header('ANALYSIS REGIONS')
        if hasattr(ubSource, 'description'):
            core.paragraph(ubSource.description)

        core.divider()
        core.header('SOLUTION')

        statClass = analysis.getStat()
        #One alternative is to put getDescription in MagicStatFactory-hierarchy as class-method, and get real class behind partial-object.
        #if isinstance(statClass, functools.partial):
        #statClass = statClass.func
        #core.paragraph( statClass.getDescription() )

        #Chosen alternative is to Instantiate an object, which will automatically give object of real class..
        #and then use the following two lines, which will get class in Statistic-hierarchy instead of MagicStatFactory-hierarchy ..
        try:
            reg = ubSource.__iter__().next()
        except:
            core.paragraph(
                'Solution not relevant, as there are no specified analysis regions..'
            )
        else:
            track1, track2 = analysis.getTracks()
            if statClass is None:
                core.paragraph(
                    'Solution not available, due to currently invalid analysis'
                )
                logMessage('Solution not available, with params: ' +
                           str([trackNames[0], trackNames[1], analysisDef]),
                           level=logging.WARN)
            else:
                statObj = statClass(reg, track1, track2)
                statDescr = statObj.getDescription()
                replPat = '<a href=' + os.sep.join(
                    [STATIC_REL_PATH, 'notes', 'stats', '']) + r'\1>note</a>'
                statDescr = re.sub('<note>(.*)</note>', replPat, statDescr)

                core.paragraph(statDescr)

        core.divider()
        core.header('TIME OF ANALYSIS')
        core.paragraph('Analysis initiated at time: ' +
                       str(datetime.datetime.now()))

        if urlForTrackAutoSelection not in [None, '']:
            core.divider()
            core.header('URL FOR TRACK AUTOSELECTION')
            #urlOptions = '&'.join(['track1=' + quote(':'.join(trackName1)), 'track2=' + quote(':'.join(trackName2))])
            #core.paragraph(URL_PREFIX + '/hyper?' + urlOptions)
            core.styleInfoBegin(styleClass='break-word')
            core.paragraph(urlForTrackAutoSelection)
            core.styleInfoEnd()

        if revEngBatchLine not in [None, '']:
            core.divider()
            core.header('CORRESPONDING BATCH COMMAND LINE')
            #if any(ExternalTrackManager.isRedirectOrExternalTrack(tn) for tn in [trackName1, trackName2]):
            #core.paragraph('Batch-run line not available with tracks from history')
            #else:
            core.styleInfoBegin(styleClass='break-word')
            core.paragraph(revEngBatchLine)
            core.styleInfoEnd()

        core.divider()
        core.header('REFERENCES')
        core.paragraph(
            'The HyperBrowser system is described in:<br>"Sandve et al., <a href="http://genomebiology.com/2010/11/12/R121/">The Genomic HyperBrowser: inferential genomics at the sequence level</a>, Genome Biol. 2010;11(12):R121'
        )
        from gold.statistic.RandomizationManagerStat import RandomizationManagerStat
        if statClass is not None and RandomizationManagerStat.getMcSamplingScheme(
                statClass.keywords) == 'MCFDR':
            core.paragraph('The p-values of this analysis were computed using the MCFDR scheme for Monte Carlo based p-value computation'+\
                           ', described in:<br>Sandve et al., <a href="http://bioinformatics.oxfordjournals.org/content/early/2011/10/13/bioinformatics.btr568.long">Sequential Monte Carlo multiple testing</a>, Bioinformatics 2011')

#        description = \
#'''
#Run descriptions will be introduced in the next version of HB. <br>
#Below is an example run description, which is a static text unconnected to your choices. The purpose is to get feedback from you on what this should look like:<br>
#Track1 (refseg:genes): Unmarked points (converted from unmarked segments, taking midpoints)<br>
#Track2 (DNA melting:meltmap): Function<br>
#Bins: Chr1, divided into bins of 10 megabases<br>
#Question: Are track1-points occurring with different frequency inside track2-segment than outside?<br>
#Analysis:<br>
#The main result is a p-value resulting from a statistical test connected to the question.<br>
#The null-hypothesis assumes that the track1-points are randomly distributed according to a poisson-distribution, with the same number of points as in the original data. Track2-segment are assumed fixed as they are in the original data. This can be answered by a binomial test. The alternative hypothesis is then that the count of points inside segments has resulted from a different distribution of points, where the points are then either distributed more or less inside segments versus outside. See the note on this question in the user guide for further info.<br>
#'''
        return str(core)
コード例 #16
0
    def validateAndReturnErrors(cls, choices):
        """
        Should validate the selected input parameters. If the parameters are not
        valid, an error text explaining the problem should be returned. The GUI
        then shows this text to the user (if not empty) and greys out the
        execute button (even if the text is empty). If all parameters are valid,
        the method should return None, which enables the execute button.
        :param choices:  Dict holding all current selections
        """
        from quick.toolguide.controller.ToolGuide import ToolGuideController
        from quick.toolguide import ToolGuideConfig

        if not choices.queryTrack and not choices.gsuite:
            return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.TRACK_INPUT, ToolGuideConfig.GSUITE_INPUT],
                                               choices.isBasic)
        if not choices.queryTrack:
            return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.TRACK_INPUT], choices.isBasic)
        if not choices.gsuite:
            return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.GSUITE_INPUT], choices.isBasic)

        errorString = cls._checkGSuiteFile(choices.gsuite)
        if errorString:
            return errorString

        errorString = cls._validateGenome(choices)
        if errorString:
            return errorString

        errorString = cls._checkTrack(choices, 'queryTrack', 'genome')
        if errorString:
            return errorString

        gsuite = getGSuiteFromGalaxyTN(choices.gsuite)

        errorString = cls._checkGSuiteRequirements \
            (gsuite,
             cls.GSUITE_ALLOWED_FILE_FORMATS,
             cls.GSUITE_ALLOWED_LOCATIONS,
             cls.GSUITE_ALLOWED_TRACK_TYPES,
             cls.GSUITE_DISALLOWED_GENOMES)

        if errorString:
            return errorString

        errorString = cls._checkGSuiteTrackListSize(gsuite)
        if errorString:
            return errorString

        if choices.randStrat in [RAND_BY_UNIVERSE_TEXT]:
            errorString = cls._checkTrack(choices, 'intensityTrack', 'genome')
            if errorString:
                return errorString

            if choices.queryTrack and choices.intensityTrack:
                basicTFQuery = cls._getBasicTrackFormat(choices, 'queryTrack')[-1]
                basicTFIntensity = cls._getBasicTrackFormat(choices, 'intensityTrack')[-1]

                if not all(_ == 'points' for _ in [basicTFQuery, basicTFIntensity]):
                    core = HtmlCore()
                    core.paragraph('The selected randomization strategy requires the query and '
                                   'the universe track to both be of type "Points". One or both '
                                   'of these tracks have the incorrect track type.')
                    core.descriptionLine('Current track type of query track', basicTFQuery)
                    core.descriptionLine('Current track type of universe track', basicTFIntensity)
                    core.paragraph('The only file formats (Galaxy datatypes) that '
                                   'support the "Points" track type is "gtrack" and "bed.points". '
                                   'To fix your input track(s), do as follows:')
                    core.orderedList([
                        'If you currently have a segment track (with segment lengths > 1), '
                        'please convert it into points tracks by using the tool "Expand or '
                        'contract points/segments" under the "Customize tracks" submenu.',
                        'If you currently have a "bed" file where all segments have '
                        'length one, possibly as the result of step 1, you will need to '
                        'change the Galaxy datatype to "point.bed". To do this, click the '
                        '"pencil" icon of the history element, select the "Datatypes" tab '
                        'and select "point.bed".'])
                    return str(core)

        errorString = cls.validateUserBins(choices)
        if errorString:
            return errorString
コード例 #17
0
    def getToolDescription(cls):
        '''
        Specifies a help text in HTML that is displayed below the tool.
        '''

        core = HtmlCore()
        core.paragraph('This tool is used to specify a set of analyses to be run in sequence, defined via a set of ' + \
                       str(HtmlCore().emphasize('batch command lines')) + '.')
        core.paragraph('Batch command lines can be found by ' +\
                       'clicking the "Inspect parameters of this analysis" link, either from the "Analyze genomic tracks" tool ' +\
                       'interface, or from the history element of previously run analyses. These batch run lines can then ' +\
                       'be copied to this tool and duplicated or modified if needed.')
        core.paragraph('The batch command lines are executed in sequence, that is, ' +\
                       'each batch command line is started only after the previous line has been fully executed.')

        core.divider()
        core.smallHeader('Batch command line format')
        core.styleInfoBegin(styleClass='debug')
        core.append('genome|regions|binsize|track1|track2|statistic')
        core.styleInfoEnd()
        core.descriptionLine('genome', 'The short name of the reference genome for the analysis (can be found in ' +\
                                        'the genome info box of the "Analyze genomic tracks" tool)', emphasize=True)
        core.descriptionLine('regions', 'The regions where the analysis should be performed, in the following format:' +\
                                        cls._exampleText('seqid[:start-[end]],seqid[:start-[end]],...') +\
                                        str(HtmlCore().descriptionLine('seqid', 'The sequence id of the region, e.g. "chr1" for chromosome 1', \
                                                                       emphasize=True)) +\
                                        str(HtmlCore().descriptionLine('start', 'The start position of the region. If the start position ' +\
                                                                                'is omitted, the region starts at posision 1.', emphasize=True)) +\
                                        str(HtmlCore().descriptionLine('seqid', 'The end position of the region. If the end position is ' +\
                                                                                'omitted, the region ends at the end of the specified ' +\
                                                                                'sequence (e.g. chromosome 1).', emphasize=True)) +\
                                        'Note:' + str(HtmlCore().unorderedList( \
                                            ['All positions are 1-based, and end-inclusive (i.e. the first base pair ' +\
                                                'of the sequence has position 1, and the end position is included in the region). ', \
                                             str(HtmlCore().emphasize('k')) + ' and ' + str(HtmlCore().emphasize('m')) +\
                                                ' can be used for specifying thousand (kilo) and million (mega) base pairs, ' +\
                                                'respectively (e.g. "chr1:1k-2k" corresponds to "chr1:1001-2000").', \
                                             '* denotes all (standard) sequences of the reference genome, e.g. all chromosomes'])) +\
                                        'Examples: ' +\
                                        cls._exampleText('chr1,chr2\nchr1:1001-1500\nchr2:1m-2m,chr2:3m-\n*'), emphasize=True)
        core.descriptionLine('binsize', 'The regions are further divided into smaller bins of this size. ' +\
                                        str(HtmlCore().indent( \
                                        'Note:' + str(HtmlCore().unorderedList( \
                                            [str(HtmlCore().emphasize('k')) + ' and ' + str(HtmlCore().emphasize('m')) +\
                                                ' denotes thousand and million base pairs, respectively', \
                                             '* denotes that the regions are not subdivided.'])) +\
                                        'Examples: ' +\
                                        cls._exampleText('5000\n100k\n*'))), emphasize=True)
        core.descriptionLine('track1', 'The first track of the analysis. ' +\
                                        str(HtmlCore().indent( \
                                        'Note:' + str(HtmlCore().unorderedList( \
                                            ['Colon, ":", is used to separate the different levels of the track hierarchy', \
                                             str(HtmlCore().link('URL-encoding', 'http://www.w3schools.com/tags/ref_urlencode.asp')) + \
                                                ' is supported, as non-ASCII characters will not work', \
                                            'A special format, starting with "galaxy", is used to represent a track from history'])) +\
                                        'Examples: ' +\
                                        cls._exampleText('Genes and gene subsets:Genes:CCDS\n' +\
                                                                  'Sequence:Repeating%20elements:SINE\ngalaxy:bed:%2Fusit%2Finvitro' +\
                                                                  '%2Fdata%2Fgalaxy%2Fgalaxy-dist-hg-stable%2Fdatabase%2Ffiles%2F028' +\
                                                                  '%2Fdataset_28276.dat:3%20-%20Extract%20track'))), emphasize=True)
        core.descriptionLine('track2', 'The second track of the analysis, specified in the same way as the first track. ' +\
                                        'If only a single track is to be analyzed, this field should be left empty', emphasize=True)
        core.descriptionLine('statistic', 'The specification of the analysis to run, and its parameters, in the following format:' +
                                        str(HtmlCore().indent( \
                                        cls._exampleText('statisticClass(paramA=valueA,paramB=valueB,...)') +\
                                        'The exact specification possibilities, with different statistic classes and parameter values, ' +\
                                        'are diverse and extensive. However, one may easily find a particular specification by ' +\
                                        'specifying the analysis and parameters in the "Analyze genomic tracks" tool and clicking the ' +\
                                        '"Inspect parameters of this analysis" link.')), emphasize=True)

        core.divider()
        core.smallHeader('Region specification variants')
        core.paragraph(
            'Other specifications of analysis regions are also supported, using both "regions" and "binsize" fields, as follows:'
        )
        core.tableHeader([
            'regions',
            'binsize (example)',
            'description',
        ])
        core.tableLine([cls._exampleText('__brs__'), cls._exampleText(''), \
            'Use the bounding region of the track if only one track is specified, else use the intersection '
            'of the bounding regions of the two tracks'])
        core.tableLine([cls._exampleText('__chrs__'), cls._exampleText('chr1,chr2'), \
            'List of complete sequence ids of the reference genome, e.g. chromosome names'])
        core.tableLine([cls._exampleText('__chrArms__'), cls._exampleText('chr1q,chr2p'), \
            'List of chromosome arm names. (Note: not supported for all reference genomes)'])
        core.tableLine([cls._exampleText('__genes__'), cls._exampleText('ENSG00000208234,ENSG00000199674'), \
            'List of Ensembl gene ids. (Note: not supported for all reference genomes)'])
        core.tableLine([''.join([cls._exampleText(x) for x in ['bed','gff','wig','bedgraph','gtrack']]), \
                        cls._exampleText('/usit/invitro/data/galaxy/galaxy-dist-hg-stable/database/files/028/dataset_28276.dat'), \
                        'Internal path to a file of the specified format, containing custom regions'])
        core.tableFooter()

        core.divider()
        core.smallHeader('Multiple run expansion')
        core.paragraph('The batch command line format supports two options for automatic expansion of a single batch ' +\
                       'command line into multiple batch lines, thus supporting multiple analyses from a single line:')
        core.orderedList(['Multiple values of the ' + str(HtmlCore().emphasize('track1')) + ', ' + str(HtmlCore().emphasize('track2')) + ', and' +\
                          str(HtmlCore().emphasize('statistic')) + ' fields can be specified using the slash character, "/", as ' +\
                          'separator. If more than one field is specified this way, all combinations of the values are expanded and ' +\
                          'executed. Example expansion:' + \
                          cls._exampleText('hg18|*|*|Genes and gene subsets:Genes:CCDS/Genes and gene subsets:Genes:Refseq||ProportionCountStat()/CountPointAllowingOverlapStat()') + \
                          'This expands to the following lines internally:' + \
                          cls._exampleText('hg18|*|*|Genes and gene subsets:Genes:CCDS||ProportionCountStat()\n' +\
                                                    'hg18|*|*|Genes and gene subsets:Genes:CCDS||CountPointAllowingOverlapStat()\n' +\
                                                    'hg18|*|*|Genes and gene subsets:Genes:Refseq||ProportionCountStat()\n' +\
                                                    'hg18|*|*|Genes and gene subsets:Genes:Refseq||CountPointAllowingOverlapStat()'),
                          'All tracks under a specific hierarchy can be specified using the "*" character. This works for ' +\
                          'values of the ' + str(HtmlCore().emphasize('track1')) + ' and ' + str(HtmlCore().emphasize('track2')) +\
                          ' fields. This expansion is also combinatorical, in the same manner as with the "/" character, and can ' +\
                          'be freely combined with such notation. Example:' + \
                          cls._exampleText('hg19|*|*|Genes and gene subsets:Genes:*|Chromatin:Chromatin State Segmentation:wgEncodeBroadHmmK562HMM:*|DerivedOverlapStat()') +\
                          'This batch command line will result in 30 analyses (2 gene tracks * 15 chromatin tracks).'])
        core.divider()
        core.smallHeader('Defining variables')
        core.paragraph('The batch command line format allows definition of variables using the following format:' +\
                       cls._exampleText('@variable=value') +\
                       'To use a variable, simply enter the variable name with a starting "@" character in a batch ' +\
                       'command line. Example:' +\
                       cls._exampleText('@trackname=Genes and gene subsets:Genes:CCDS\nhg18|*|*|@trackname||ProportionCountStat()') +\
                       'Nested variable declarations, i.e. defining a variable using previously defined variables, are also allowed. Example:' +\
                       cls._exampleText('@TN1=Genes and gene subsets:Genes:CCDS\n' +\
                                  '@TN2=Genes and gene subsets:Genes:Refseq\n' +\
                                  '@TNs=@TN1/@TN2\n' +\
                                  'hg18|*|*|@TNs||ProportionCountStat()/CountPointAllowingOverlapStat()') +\
                       'Note:' +\
                        str(HtmlCore().unorderedList(['The variable names are case sensitive', \
                                                      '"=" characters are allowed in variable values'])))

        return str(core)