Beispiel #1
0
 def _add_tracks(data_list, view, default_tracktype):
     for data_obj in data_list:
         kwargs = data_obj.obj.get('trackinfo', {})
         kwargs = dict((k, str(v)) for k, v in kwargs.items())
         kwargs.setdefault('tracktype', default_tracktype)
         view.add_tracks(
             Track(
                 name=sanitized_label + utils.sanitize(data_obj.label),
                 short_label=data_obj.label,
                 long_label=data_obj.obj['long_label'],
                 local_fn=data_obj.processed,
                 **kwargs))
Beispiel #2
0
 def _add_tracks(data_list, view, default_tracktype):
     for data_obj in data_list:
         kwargs = data_obj.obj.get('trackinfo', {})
         kwargs = dict((k, str(v)) for k, v in kwargs.items())
         kwargs.setdefault('tracktype', default_tracktype)
         view.add_tracks(
             Track(name=sanitized_label +
                   utils.sanitize(data_obj.label),
                   short_label=data_obj.label,
                   long_label=data_obj.obj['long_label'],
                   local_fn=data_obj.processed,
                   **kwargs))
Beispiel #3
0
    def composite_track(self):
        """
        Create a composite track ready to be added to a trackhub.TrackDb
        instance.
        """
        bigwigs = [i for i in self.tracks if i.type_ == 'bigwig']
        bigbeds = [i for i in self.tracks if i.type_ == 'bigbed']
        bams = [i for i in self.tracks if i.type_ == 'bam']

        # Build the HTML docs
        last_section = self.reference_section()
        html_string = utils.reST_to_html(
            self.metadata['study'].get('description', '') + '\n' + last_section)

        sanitized_label = utils.sanitize(self.label, strict=True)

        # Composite track to hold all subtracks for the study
        composite = CompositeTrack(
            name=sanitized_label,
            short_label=self.study['short_label'],
            long_label=self.study['long_label'],
            tracktype='bigBed',

            # Add all the documentation
            html_string=html_string)

        # If there are any bigWigs defined for this study, make a new "signal"
        # subtrack in the composite and then add the bigWigs to it.
        #
        # Uses the sanitized label for the study to ensure uniqueness among
        # tracks.
        #
        def _add_tracks(data_list, view, default_tracktype):
            for data_obj in data_list:
                kwargs = data_obj.obj.get('trackinfo', {})
                kwargs = dict((k, str(v)) for k, v in kwargs.items())
                kwargs.setdefault('tracktype', default_tracktype)
                view.add_tracks(
                    Track(
                        name=sanitized_label + utils.sanitize(data_obj.label),
                        short_label=data_obj.label,
                        long_label=data_obj.obj['long_label'],
                        local_fn=data_obj.processed,
                        **kwargs))

        if len(bigwigs) > 0:
            signal_view = ViewTrack(
                name=sanitized_label + 'signalviewtrack',
                view=sanitized_label + 'signalview',
                short_label=self.label + ' signal view',
                long_label=self.label + ' signal view',
                visibility='full',
                maxHeightPixels='100:25:8',
                autoScale='off',
                tracktype='bigWig',
            )
            composite.add_view(signal_view)

            _add_tracks(bigwigs, signal_view, 'bigWig')

        # Same thing with bigBeds
        if len(bigbeds) > 0:
            bed_view = ViewTrack(
                name=sanitized_label + 'bedviewtrack',
                view=sanitized_label + 'bed_view',
                short_label=self.label + ' bed view',
                long_label=self.label + ' bed view',
                visibility='dense',
            )
            composite.add_view(bed_view)
            _add_tracks(bigbeds, bed_view, 'bigBed 9')
        # and bams
        if len(bams) > 0:
            bam_view = ViewTrack(
                name=sanitized_label + 'bamviewtrack',
                view=sanitized_label + 'bam_view',
                short_label=self.label + ' bam view',
                long_label=self.label + ' bam view',
                visibility='dense',
            )
            composite.add_view(bam_view)
            _add_tracks(bams, bam_view, 'bam')

        return composite
Beispiel #4
0
    def composite_track(self):
        """
        Create a composite track ready to be added to a trackhub.TrackDb
        instance.
        """
        bigwigs = [i for i in self.tracks if i.type_ == 'bigwig']
        bigbeds = [i for i in self.tracks if i.type_ == 'bigbed']

        # Build the HTML docs
        last_section = self.reference_section()
        html_string = utils.reST_to_html(
            self.metadata['study'].get('description', '') + '\n' +
            last_section)

        sanitized_label = utils.sanitize(self.label, strict=True)

        # Composite track to hold all subtracks for the study
        composite = CompositeTrack(
            name=sanitized_label,
            short_label=self.study['short_label'],
            long_label=self.study['long_label'],
            tracktype='bigBed',

            # Add all the documentation
            html_string=html_string)

        # If there are any bigWigs defined for this study, make a new "signal"
        # subtrack in the composite and then add the bigWigs to it.
        #
        # Uses the sanitized label for the study to ensure uniqueness among
        # tracks.
        #
        def _add_tracks(data_list, view, default_tracktype):
            for data_obj in data_list:
                kwargs = data_obj.obj.get('trackinfo', {})
                kwargs = dict((k, str(v)) for k, v in kwargs.items())
                kwargs.setdefault('tracktype', default_tracktype)
                view.add_tracks(
                    Track(name=sanitized_label +
                          utils.sanitize(data_obj.label),
                          short_label=data_obj.label,
                          long_label=data_obj.obj['long_label'],
                          local_fn=data_obj.processed,
                          **kwargs))

        if len(bigwigs) > 0:
            signal_view = ViewTrack(
                name=sanitized_label + 'signalviewtrack',
                view=sanitized_label + 'signalview',
                short_label=self.label + ' signal view',
                long_label=self.label + ' signal view',
                visibility='full',
                maxHeightPixels='100:25:8',
                autoScale='off',
                tracktype='bigWig',
            )
            composite.add_view(signal_view)

            _add_tracks(bigwigs, signal_view, 'bigWig')

        # Same thing with bigBeds
        if len(bigbeds) > 0:
            bed_view = ViewTrack(
                name=sanitized_label + 'bedviewtrack',
                view=sanitized_label + 'bed_view',
                short_label=self.label + ' bed view',
                long_label=self.label + ' bed view',
                visibility='dense',
            )
            composite.add_view(bed_view)
            _add_tracks(bigbeds, bed_view, 'bigBed 9')

        return composite