Пример #1
0
        except StopIteration:
            return
        return cls(target, coord)

    def run(self):
        pdb_ids_category = self.target.sequence_information.setdefault('pdb-ids')
        new_entries = []
        for i, etree_entry in enumerate(self.target.sequence_information.categories['uniprot-etree']):
            if pdb_ids_category[i]:
                continue
            pdb_ids_entry = PDBStructures.from_uniprot_etree(etree_entry)
            if pdb_ids_entry:
                new_entries.append(pdb_ids_entry)
        self.target.sequence_information.add_entries(new_entries)
        
register_action(FindPDBStructuresForUniprotSequences)
    
class ImportPDBStructuresForUniprotSequence(Action):
    action_name = 'import-pdb-structures-for-sequence'
    path = ['Import', 'Sequence information', 'Download PDB structure links (single sequence)']
    tooltip = 'Download PDB structure links from UniProtKB XML data for the sequence.'
    
    url = 'http://www.uniprot.org/uniprot/' 

    @classmethod
    def applicable(cls, target, coord=None):
        if not coord or coord.sequence is None:
            return
        if target.msaview_classname != 'data.msa':
            return
        etree_entry = target.sequence_information.get_entry('uniprot-etree', coord.sequence)
Пример #2
0
                details.append(structure.method)
            if structure.chains is not None:
                details.append(structure.chains)
            if details:
                label += ' (%s)' % ', '.join(details) 
            a.path[-1] %= label
            actions.append(a)
        return actions
    
    def get_options(self):
        return [Option(None, 'pymolscript', 'default', 'default', 'Pymol script', 'How the structure should be visualized in pymol (the preset name of a pymol_script)')]
    
    def set_options(self, options):
        Action.set_options(self, options)
        self.params['pymolscript'] = presets.get_value('pymolscript:' + self.params['pymolscript'])
    
    def run(self):
        structure = self.params['structure']
        startup_script = self.fetch_cmd % structure.id
        startup_script += self.params['pymolscript']
        _buggy_pymol_parser = True
        if _buggy_pymol_parser:
            argv = sum((['-d', s] for s in startup_script.splitlines()), [PYMOL_PATH])
            p = subprocess.Popen(argv, stdin=subprocess.PIPE)
        else:
            p = subprocess.Popen([PYMOL_PATH, '-p'], stdin=subprocess.PIPE)
            p.stdin.write(startup_script)
        p.stdin.close()

register_action(ShowStructureInPymol)
    
Пример #3
0
    @classmethod
    def applicable(cls, target, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target.features)
        if target.msaview_classname == 'data.sequence_features':
            return cls(target)
    
    def get_options(self):
        path = ''
        if self.target and self.target.msa.path:
            path = self.target.msa.path + '.hmmsearch'
        return [Option(propname='location', default=path, value=path, nick='Location', tooltip='The hmmsearch result file to parse.')]

    def run(self):
        features = []
        for feature in iter_domains(open(self.params['location'])):
            feature.sequence_index = get_id_index(self.target.msa.ids, feature.sequence_id)
            if feature.sequence_index is None:
                continue
            feature.mapping = map_region_to_msa(feature.region, self.target.msa.msa_positions[feature.sequence_index])
            if feature.mapping is None:
                continue
            features.append(feature)
        self.target.add_features(features)

    
register_action(ImportHMMSearchResults)

#presets.add_to_preset_path(__file__)

Пример #4
0
    path = ['Open', 'Clustal format alignment']
    tooltip = 'Read a Clustal format alignment file.'

    @classmethod
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target)

    def get_options(self):
        return [Option(propname='location', default='', value='', nick='Location', tooltip='The alignment file to read.')]

    def run(self):
        msa = ClustalFormatMSA.from_text(open(self.params['location']))
        self.target.set_msa(msa.sequences, self.params['location'], msa.ids)
    
register_action(ReadClustalMSA)

class SaveClustalMSA(Action):
    action_name = 'save-clustal-alignment'
    path = ['Save', 'Clustal like alignment']
    tooltip = 'Save the alignment in Clustal like format (without conservation punctuation).'

    @classmethod
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target)

    def get_options(self):
        try:
            path = os.path.splitext(self.target.path)[0] + '.aln'
        except:
Пример #5
0
            return cls(target)

    def get_options(self):
        return [Option(propname='id', default='', value='', nick='Pfam ID', tooltip='The Pfam ID for the family.'),
                BooleanOption(propname='full', default=False, value=False, nick='Full Alignment', tooltip='Retrieve the full alignment instead of just the seed.')]

    def run(self):
        url = "http://pfam.sanger.ac.uk/family/alignment/download/gzipped?acc=%s&alnType=%s"
        url %= self.params['id'], ('full' if self.params['full'] else 'seed') 
        tmp = StringIO.StringIO(urllib2.urlopen(url).read())
        alignment = gzip.GzipFile(fileobj=tmp)
        msa = StockholmFormatMSA.from_text(alignment)
        path = "%s-%s" % (self.params['id'], ('full' if self.params['full'] else 'seed'))
        self.target.set_msa(msa.sequences, path, msa.ids, msa.descriptions)
   
register_action(DownloadPfamAlignment)
 
class OpenPfamAlignment(Action):
    action_name = 'open-pfam-alignment'
    path = ['Open', 'Pfam alignment']
    tooltip = 'Open a Pfam family alignment from the Pfam website.'

    @classmethod
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target)

    def get_options(self):
        return [Option(propname='location', default='', value='', nick='Location', tooltip='The alignment file to read.')]

    def run(self):
Пример #6
0
            sequence_id = (id_entry and id_entry.sequence_id)
            if sequence_id:
                id_enumeration.append((sequence_index, sequence_id))
        self.target.features.add_features(features)
        task = UniprotXMLDownloadTask(self.target, id_enumeration, self.batch_size)
        def add_new_features(t, progress, finished, entries):
            for entry in entries or []:
                new_features = get_uniprot_features(entry, self.target)
                self.target.features.add_features(new_features)
        task.connect('progress', add_new_features)
        task.connect('progress', lambda t, progress, finished, entries: self.target.sequence_information.add_entries(entries or []))
        self.target.sequence_information.connect('changed', task.handle_id_category_changed)
        self.target.get_compute_manager().timeout_add(100, task)
        return task

register_action(ImportUniprotFeatures)

class ImportUniprotFeaturesForSequence(Action):
    action_name = 'import-uniprot-features-for-sequence'
    path = ['Import', 'Sequence features', 'UniProtKB annotations (single sequence)']
    tooltip = 'Import feature annotations for the sequence from UniProtKB.'
    
    @classmethod
    def applicable(cls, target, coord=None):
        if not coord or coord.sequence is None:
            return
        if target.msaview_classname != 'data.msa':
            return
        if (target.sequence_information.get_entry('uniprot-etree', coord.sequence) or
            target.sequence_information.get_entry('uniprot-id', coord.sequence)):
            return cls(target, coord)
Пример #7
0
        except StopIteration:
            return
        return cls(target, coord)

    def run(self):
        ensembl_ids_category = self.target.sequence_information.setdefault('ensembl-ids')
        new_entries = []
        for i, etree_entry in enumerate(self.target.sequence_information.categories['uniprot-etree']):
            if ensembl_ids_category[i]:
                continue
            entry = EnsemblIDs.from_uniprot_etree(etree_entry)
            if entry:
                new_entries.append(entry)
        self.target.sequence_information.add_entries(new_entries)
        
register_action(FindEnsemblIDsForUniprotSequences)

class ImportEnsemblIDsForUniprotSequence(Action):
    action_name = 'import-ensembl-ids-for-sequence'
    path = ['Import', 'Sequence information', 'Download Ensembl links (single sequence)']
    tooltip = 'Download Ensembl links from UniProtKB XML data for the sequence.'
    
    url = 'http://www.uniprot.org/uniprot/' 

    @classmethod
    def applicable(cls, target, coord=None):
        if not coord or coord.sequence is None:
            return
        if target.msaview_classname != 'data.msa':
            return
        etree_entry = target.sequence_information.get_entry('uniprot-etree', coord.sequence)
Пример #8
0
    path = ['Open', 'Nexus format alignment']
    tooltip = 'Read a Nexus format alignment file.'

    @classmethod
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target)

    def get_options(self):
        return [Option(propname='location', default='', value='', nick='Location', tooltip='The alignment file to read.')]

    def run(self):
        msa = NexusFormatMSA.from_text(open(self.params['location']))
        self.target.set_msa(msa.sequences, self.params['location'], msa.ids)
    
register_action(ReadNexusMSA)

class SaveCopyNexusMSA(Action):
    action_name = 'save-copy-nexus-alignment'
    path = ['Save', 'Nexus alignment (copy)']
    tooltip = 'Save a copy of the alignment in Nexus format.'

    @classmethod
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa' and target.sequences:
            return cls(target)

    def get_options(self):
        try:
            path = os.path.splitext(self.target.path)[0] + '.nxs'
        except:
Пример #9
0
        
    def get_options(self):
        location = ''
        if self.target:
            if self.target.path:
                location = os.path.dirname(self.target.path)
            location = os.path.join(location, self.target.ids[self.coord.sequence] + '.disopred')
        return [Option(None, 'location', location, location, 'Location', 'Disopred prediction file to load.')]
    
    def run(self):
        f = open(self.params['location'])
        prediction = DisopredPrediction.from_file(f)
        f.close()
        if not prediction:
            return
        sequence_index = self.coord.sequence
        offset = prediction.sequence.find(self.target.unaligned[sequence_index])
        if offset < 0:
            return
        msa_positions = self.target.msa_positions[sequence_index]
        sequence_id = self.target.ids[sequence_index]
        features = []
        for region in prediction.regions:
            mapping = map_region_to_msa(region, msa_positions, offset)
            if not mapping:
                continue
            features.append(SequenceFeature(sequence_index, sequence_id, 'disopred', 'natively disordered', region, mapping))
        self.target.features.add_features(features)

action.register_action(ImportDisopredRegions)
Пример #10
0
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target)

    def get_options(self):
        return [Option(propname='location', default='', value='', nick='Location', tooltip='The alignment file to read.')]

    def run(self):
        if self.params['location'].endswith('.gz'):
            alignment = gzip.GzipFile(self.params['location'])
        else:
            alignment = open(self.params['location'])
        msa = StockholmFormatMSA.from_text(alignment)
        self.target.set_msa(msa.sequences, self.params['location'], msa.ids, msa.descriptions)
    
register_action(ReadStockholmMSA)

class SaveStockholmMSA(Action):
    action_name = 'save-stockholm-alignment'
    path = ['Save', 'Stockholm format alignment']
    tooltip = 'Save the alignment in Stockholm format.'

    @classmethod
    def applicable(cls, target=None, coord=None):
        if target.msaview_classname == 'data.msa':
            return cls(target)

    def get_options(self):
        try:
            path = os.path.splitext(self.target.path)[0] + '.stockholm'
        except: