Example #1
0
class Pdb2xyzr(CmdTool):
    """A pdb to xyzr format converter based on OpenBabel."""
    args = [_("pdb_file", type="file", ext="pdb")]
    out = [
        _("pdb_prep_file", file="{pdb_file.stem}_prep.pdb"),
        _("xyzr_file", file="{pdb_file.stem}.xyzr")
    ]

    def _init(self, *args, **kwargs):
        self.cmd = [
            BABEL_CMD, '-i', 'pdb', self.pdb_prep_file, '-o', 'msms',
            self.xyzr_file
        ]
        self.output_files = [self.pdb_prep_file, self.xyzr_file]

    def _pre_exec(self):
        shutil.copy(self.pdb_file, self.pdb_prep_file)

    def _post_exec(self):
        if os.path.getsize(self.xyzr_file) == 0:
            utils.path.remove(self.xyzr_file)
        else:
            xyz_file = utils.path.mod(self.xyzr_file, ext="xyz")
            with open(self.xyzr_file, "r") as fp:
                lines = fp.readlines()
                with open(xyz_file, "w") as fp_out:
                    fp_out.write("%i\ncomment\n" % len(lines))
                    for d in lines:
                        ds = d.strip().split()
                        if not len(ds):
                            continue
                        l = "F\t%0.3f\t%0.3f\t%0.3f\n" % (float(
                            ds[0]), float(ds[1]), float(ds[2]))
                        fp_out.write(l)
Example #2
0
class SpiderDeleteBackbone (Spider):
    args = [
     _( "map_file", type="file", ext="cpv" ),
     _( "pdb_file", type="file", ext="pdb" ),
     _( "pixelsize", type="float", range=[0, 10] )
        
            
     ]
    out = [
        _( "edited_pdb_file", file="nobb.pdb" ),
        _( "delete_map_file", file="deletebb.cpv" )
                
    ]
    script_tmpl = "delete_backbone.spi"
    def _init( self, *args, **kwargs ):
        super(SpiderDeleteBackbone, self)._init( "__tmpl__" )    
    def _pre_exec( self ):
        backbone = ( ' N  ',' C  ', ' CA ',' O  ' )
        npdb=NumPdb( self.pdb_file )
        back=npdb.sele(atomname=backbone)
        npdb.copy(sele=back).write('nobb.pdb')
        self._make_script_file(
            map_name=self.relpath(self.map_file, no_ext=True) ,
            pixelsize=self.pixelsize,
            pdb_file='nobb.pdb'
        )
Example #3
0
class SplitPdbSSE (PyTool) :
    args = [
            _( "pdb_file", type="dir" )            
        ]
    out = [
            _( "pieces_dir", dir="pieces" )
        ]
    def func( self ):
        npdb = numpdb.NumPdb( self.pdb_file, {
            "phi_psi": False,
            "sstruc": True,
            "backbone_only": False,
            "protein_only": False,
            "detect_incomplete": False,
            "configuration": False,
            "info": False
        })
        for i, numa in enumerate( npdb.iter_sstruc() ):
            print numa["chain"][0], numa["resno"].min(), numa["resno"].max()
            print numa.sequence()
            values_dic ={}
            values_dic[1]=numa['resno'][0]
            values_dic[2]=numa['resno'][-1]
            values_dic[3]=numa.sequence()
            values_dic[4]=numa['chain'][0]
            if not os.path.exists(self.pieces_dir):
                os.makedirs(self.pieces_dir)
            file_name=os.path.join(self.pieces_dir,  "%s_%s_%i-%i.%s" % (self.pdb_file[-8:-4],numa['chain'][0],numa['resno'][0],numa['resno'][-1],'pdb'))
            file_namej=os.path.join(self.pieces_dir, "%s_%s_%i-%i.%s" % (self.pdb_file[-8:-4],numa['chain'][0],numa['resno'][0],numa['resno'][-1],'json'))
            numa.write(file_name)
            with open(file_namej, "w" ) as fp:
                json.dump( values_dic,fp, indent=4 )
Example #4
0
class SpiderCropMap ( Spider ):
    args = [
        _( "map_file", type="file", ext="cpv" ),
        _( "pdb_file", type="file", ext="pdb" ),
        _( "pixelsize", type="float", range=[1, 10], fixed=True )
    ]
    out = [
        _( "box_file", file="ergebnisse.cpv" ),
        _( "box_map_file", file="boxil.cpv" )
    ]
    script_tmpl = "crop2.spi"
    def _init( self, *args, **kwargs ):
        super(SpiderCropMap, self)._init( "__tmpl__" )    
    def _pre_exec (self):
        npdb = NumPdb( self.pdb_file )
        psf=1/self.pixelsize
        schrumpf=npdb['xyz']*psf
        #te=
        ma=np.amax(schrumpf, axis=0)
        mi=np.amin(schrumpf,axis=0)
        middle=[(mi[0]+ma[0])/2,(mi[1]+ma[1])/2,(mi[2]+ma[2])/2]
        abstand=round(((mi[0]-ma[0])**2+(mi[1]-ma[1])**2+(mi[2]-ma[2])**2)**0.5,0)
        print ma,mi,middle,abstand
        self._make_script_file(
            x1=middle[0],
            y1=middle[1],
            z1=middle[2],
            map_name=self.relpath(self.map_file, no_ext=True),
            abstand=abstand,
            ps=self.pixelsize,
        )
Example #5
0
class OpmList(PyTool):
    args = [
        _("class_id", type="str"),
    ]
    out = [_("list_file", file="opm_list_class_{class_id}.json")]

    def func(self):
        list_record = opm_list(self.class_id)
        ListIO(self.list_file).write(list_record)
Example #6
0
class LoopRotamerOptimize ( PyTool ):
    args = [
    _("pdb_file", type="file"),  
    _("result_direc",type="str"),
    _("residue_1",type="int"),
    _("residue_2",type="int")
    ]
    out=[
    _( "verybestrotamers", file="verybestrotamers.pdb" )
    
    ]
   # clashes fuer das ganze Protein bestimmen
    def func (self):
        npdb=NumPdb( self.pdb_file )
        clashes,a=find_all_clashes(npdb)
        gtree=get_tree(npdb['xyz'])
        lclashes=[]
        print clashes
        resi=range(self.residue_1,self.residue_2)
        print resi
        for i in clashes:
            print i[0], i[1]
            if (i[0] or i[1]) in resi:
                lclashes.append(i)
            else:
                continue
        for x in lclashes:
            print x 
        
            as1=x[0]
            as2=x[1]
            resname100=npdb.get('resname',resno=as1)[0]
            resname101=npdb.get('resname',resno=as2)[0]
            #    #print resname100, resname101, i
            if (resname100 and resname101) not in ('ALA','GLY'):
                    chain100=npdb.get('chain',resno=as1)[0]
                    chain101=npdb.get('chain',resno=as2)[0]
                    #print resname101
                    resno1=get_rotno(resname100)
                    resno2=get_rotno(resname101)
                    if resno1 >= resno2 :
            #            #print "anzahl rota" ,resno1,resno2
                        sele={'resno':as1}
                        atom_no= npdb.index(**sele)
            #            #erster clashpartner
                        rotadir="%s_%s_%i" % (chain100,resname100,as1)
                        ccsortpath=os.path.join(self.result_direc,rotadir)
                        ccsort="%s/%s" % (ccsortpath,'ccsort.cpv')
                    else:
                        sele={'resno':as2}
                        atom_no= npdb.index(**sele)
                        rotadir="%s_%s_%i" % (chain101,resname101,as2)
                        ccsortpath=os.path.join(self.result_direc,rotadir)
                        ccsort="%s/%s" % (ccsortpath,'ccsort.cpv')
Example #7
0
class MakeAllRotameres( PyTool ):
    args = [
        _( "pdb_input", type="file", ext="pdb" ),
        _( "chain|ch", type="str" ),
        _( "resno|r", type="int" ),
        _( "zfill", type="int", range=[0, 8], default=0 )
    ]
    #out = [
    #    _( "rotamere_file", file="{pdb_input.stem}.pdb" )
    #]
    def func( self, *args, **kwargs ):
        make_all_rotameres( self.pdb_input, self.chain, self.resno ,self.zfill, self.output_dir)
Example #8
0
class HBexplore(CmdTool, ProviMixin):
    """A wrapper around the 'hbexplore' programm."""
    args = [
        _("pdb_file", type="file", ext="pdb"),
        _("DAmax", type="float", default=3.9),
        _("HAmax", type="float", default=2.5),
        _("DHAmin", type="int", default=90),
        _("HAA1_DAA1min", type="int", default=90),
        _("HAhybmax", type="int", default=60),
        _("waterAsDonorAcceptor", type="int", default=1),
        _("c_hAsDonor", type="int", default=2),
    ]
    out = [
        _("params_file", file="{pdb_file.stem}_hbx.params"),
        _("hbx_file", file="{pdb_file.basename}_hbx.anal"),
    ]
    tmpl_dir = TMPL_DIR
    provi_tmpl = "hbexplore.provi"

    def _init(self, *args, **kwargs):
        self.cmd = [HBEXPLORE_CMD]
        self.cmd_input = self.params_file
        self.no_cmd = False

    def _pre_exec(self):
        with open(self.params_file, "w") as fp:
            fp.write("\n".join([
                self.relpath(self.pdb_file),
                ".",  # rel output dir
                "n",  # use_default_params
                str(self.DAmax),
                str(self.HAmax),
                str(self.DHAmin),
                str(self.HAA1_DAA1min),
                str(self.HAhybmax),
                str(self.waterAsDonorAcceptor),
                str(self.c_hAsDonor),
                "",  # separate_tables_and_distributions,
                "0",  # additional_connectivity_files,
                "",  # potential_hydrogen_bond_dataset,
                "n",  # search_for_specific_hbonds
            ]) + "\n\n")

    def _post_exec(self):
        provi.prep_hbexplore(self.hbx_file, self.pdb_file)
        self._make_provi_file(pdb_file=self.relpath(self.pdb_file),
                              hbonds_file=self.relpath(self.hbx_file +
                                                       ".bonds"))

    @memoize_m
    def get_hbonds(self):
        return parse_hbx_output(self.hbx_file)
Example #9
0
class ListJoin( PyTool ):
    args = [
        _( "list", type="file", ext="json", nargs="+" ),
        _( "list_name|ln", type="str", default=None )
    ]
    out = [
        _( "joined_list", file="joined_list.json" )
    ]
    def func( self ):
        joined_list = list_join(
            *map( lambda x: ListIO( x ).read(), self.list ),
            name=self.list_name
        )
        ListIO( self.joined_list ).write( joined_list )
Example #10
0
class LoopSidechainCorrelation (PyTool):
    args = [
     _( "map_file", type="file", ext="cpv" ),
     _( "pdb_file", type="file", ext="pdb" ),
     _( "pixelsize", type="float", range=[0, 10] ),
     _( "resolution", type="float", range=[0, 10] ),    
            
     ]
    out = [
        _( "sidechain_dir", dir="sidechains" )           
    ]
    tmpl_dir = TMPL_DIR
    def _init( self, *args, **kwargs ):
        
        self.delete_backbone= SpiderDeleteBackbone(
            self.map_file,
            self.pdb_file,
            self.pixelsize,
            **copy_dict( kwargs, run=False )
        )
    def func( self ):
        self.delete_backbone()
                
        npdb=NumPdb( self.pdb_file )
        for i, numa in enumerate( npdb.iter_resno() ):
            sele={'resno':i+1}
            resname1=numa.get('resname') [0]
            resno1=numa.get('resno') [0]
            chain1=numa.get('chain') [0]
            dirg="%s_%s_%i" %(chain1,resname1,resno1)
            
            print resname1, resno1, chain1
            if   numa.get('resname') [0] not in ('ALA', 'GLY'):
                if resname1 in  ('SER','CYS','PRO','ASP','THR','ASN','VAL','GLU','GLN'):
                    SpiderSidechainCorrelation(self.map_file, self.pdb_file, self.pixelsize,self.resolution, resno1, chain1,output_dir=self.subdir(dirg))
                else:            
                    SpiderSidechainCorrelation('deletebb.cpv', self.pdb_file, self.pixelsize,self.resolution, resno1, chain1,output_dir=self.subdir(dirg))
                aaname="%s.%s" %(dirg,'pdb')
                print aaname
                aa=npdb.sele(resname=resname1,resno=resno1)
                dire="%s/%s" %(dirg,aaname)
                npdb.copy(sele=aa).write(dire)
                OriSidechainCorrel('deletebb.cpv',dire,self.pixelsize,self.resolution,resno1,chain1,output_dir=self.subdir(dirg))
            else:
                aaname="%s.%s" %(dirg,'pdb')
                print aaname
                aa=npdb.sele(resname=resname1,resno=resno1)
                dire="%s/%s" %(dirg,aaname)
                if not os.path.exists(self.subdir(dirg)): os.makedirs(self.subdir(dirg))
                npdb.copy(sele=aa).write(dire)
Example #11
0
class Sstruc(PyTool, RecordsMixin, ParallelMixin):
    args = [
        _("pdb_input", type="file", ext="pdb"),
        _("pdb_id", type="text", default=None)
    ]
    RecordsClass = SstrucDbRecord

    def _init(self, *args, **kwargs):
        self._init_records(self.pdb_input, **kwargs)
        self._init_parallel(self.pdb_input, **kwargs)

    def func(self):
        self.records = BuildSstrucDbRecords(self.pdb_input).get()
        self.write()
Example #12
0
class Capture(PyTool, RecordsMixin, ParallelMixin, ProviMixin):
    """ CaPTURE web service wrapper (http://capture.caltech.edu/).
    """
    args = [
        _("pdb_input", type="file", ext="pdb"),
        _("parse_only", type="bool", default=False),
        _("occupancy_one", type="bool", default=False),
    ]
    out = [
        _("capture_file", file="CaPTURE_{pdb_input.stem}.txt"),
    ]
    RecordsClass = CaptureRecord
    tmpl_dir = TMPL_DIR
    provi_tmpl = "capture.provi"

    def _init(self, *args, **kwargs):
        self.pdb_id = utils.path.stem(self.pdb_input)
        self._init_records(None, **kwargs)
        self._init_parallel(self.pdb_input, **kwargs)

    def func(self):
        if not self.parse_only:
            capture_web(self.pdb_input, self.capture_file)
        self.records = [
            CaptureRecord(self.pdb_id, *x)
            for x in parse_capture(self.capture_file)
        ]
        self.write()

    def _pre_exec(self):
        if self.occupancy_one:
            occ_file = "occupancy_one.pdb"
            npdb = NumPdb(self.pdb_input)
            npdb['occupancy'] = 1.0
            npdb.write(occ_file)
            self.pdb_input = self.outpath(occ_file)

    def _post_exec(self):
        script = []
        for r in self.records:
            p = (r.es, r.chain_cation, r.resno_cation, r.chain_pi, r.resno_pi)
            s = ("var colr = color( 'rwb', -5, 5, %f ); "
                 "select { "
                 "   (chain='%s' and resno=%i) or "
                 "   (chain='%s' and resno=%i) "
                 "}; "
                 "wireframe 0.2; color @colr; " % p)
            script.append(s)
        self._make_provi_file(pdb_file=self.relpath(self.pdb_input),
                              script=" ".join(script))
Example #13
0
class SstrucInfo(PyTool):
    args = [_("pdb_file", type="file", ext="pdb"), _("sele", type="sele")]

    def _init(self, *args, **kwargs):
        pass

    def func(self):
        npdb = numpdb.NumPdb(self.pdb_file)
        self.sele["atomname"] = "CA"
        numa = npdb.copy(**self.sele)
        sstruc_order = []
        for k, g in itertools.groupby(numa['sstruc']):
            n = len(list(g))
            sstruc_order.append((k, n))
            print k, n
Example #14
0
class PdbHetDictionary( PyTool ):
    """
    Tool to extract the names of (non-standard) amino acids from
    ftp://ftp.rcsb.org/pub/pdb/data/monomers/het_dictionary.txt
    """
    args = [
        _( "het_file", type="file", ext="txt", help="hetero dictionary" )
    ]
    out = [
        _( "aa_file", file="aa.json" )
    ]
    def func( self ):
        aminoacid_list = parse_het_dictionary( self.het_file )
        with open( self.aa_file, "w" ) as fp:
            json.dump( aminoacid_list, fp )
Example #15
0
class Opm(OpmMixin, PyTool, ProviMixin):
    """A tool to access the OPM database pdb files"""
    args = [
        _("pdb_id", type="str"),
    ]
    out = [
        _("opm_file", file="{pdb_id}_opm.pdb"),
        _("mplane_file", file="{pdb_id}.mplane"),
        _("processed_file", file="{pdb_id}_proc.pdb"),
        _("info_file", file="{pdb_id}_info.json", optional=True),
    ]

    def func(self):
        with open(self.opm_file, "w") as fp:
            fp.write(opm(self.pdb_id))
Example #16
0
class SpiderCrosscorrelation( Spider ):
    args = [
        _( "map_file", type="file", ext="cpv" ),
        _( "box_map_file", type="file", ext="cpv" ),
        _( "box_file", type="file", ext="cpv" ),
        _( "loop_file", type="file", ext="pdb" ),
        _( "linkerinfo", type="file", ext="txt" ),
        _( "max_loops", type="int", range=[0, 200], default=100 )
    ]
    out = [
        _( "loop_dir", dir="loops" ),
        _( "crosscorrel_file", file="crosscorrelation.cpv" ),
        _( "crosscorrel_json", file="crosscorrelation.json" )
    ]
    script_tmpl = "crosscorrelation.spi"

    def _init( self, *args, **kwargs ):
        if not self.max_loops:
            self.max_loops = False
        super(SpiderCrosscorrelation, self)._init( "__tmpl__" )

    def _pre_exec( self ):
        self._split_loop_file()
        self._make_script_file(
            map_name=self.relpath( self.map_file, no_ext=True ),
            box_map_name=self.relpath( self.box_map_file, no_ext=True ),
            box_name=self.relpath( self.box_file, no_ext=True ),
            loop_dir=self.relpath( self.loop_dir ) + os.sep,
            max_loops=self.max_loops or 999
        )

    def _post_exec( self ):
        self._make_crosscorrel_json( compact=True )

    def _split_loop_file( self ):
        PdbSplit(
            self.loop_file, self.linkerinfo,
            output_dir=self.loop_dir, backbone_only=True,
            max_models=self.max_loops, resno_ignore=[ 1000, 2000 ], zfill=3
        )

    def _make_crosscorrel_json( self, compact=False ):
        crosscorrel_dict = {}
        with open( self.crosscorrel_file, "r" ) as fp:
            for line in fp:
                d = line.split()
                if len(d) == 3:
                    crosscorrel_dict[ int(d[0]) ] = float( d[2] )
        with open( self.crosscorrel_json, "w" ) as fp:
            if compact:
                json.dump( crosscorrel_dict, fp, separators=(',', ':') )
            else:
                json.dump( crosscorrel_dict, fp, indent=4 )
Example #17
0
class JoinSplitted( PyTool ):
    args = [
        _( "splitted_ids", type="str" ),
        _( "clear", type="bool", default=False,
            help="deletes the downloaded splited pdbs")
    ]
    out = [
        _( "all_joined", file="all_joined.pdb" )
    ]
    def _init( self, *args, **kwargs ):
        self.splitted_files=self.splitted_ids.split(',')
    def func( self ):
        self.joined = join_splitted( self.splitted_files, self.output_dir, self.clear )
    def _post_exec( self ):
        with open(self.all_joined, 'w') as fp:
            fp.write(self.joined)
Example #18
0
class MpstrucDownload(PyTool):
    """A tool to download the MPstruc database"""
    out = [_("mpstruc_xml", file="mpstruc.xml")]

    def func(self):
        with open(self.mpstruc_xml, "w") as fp:
            fp.write(mpstruc_download())
Example #19
0
class MpstrucList(PyTool):
    args = []
    out = [_("list_file", file="mpstruc_list.json")]

    def func(self):
        list_record = mpstruc_list()
        ListIO(self.list_file).write(list_record)
Example #20
0
class SpiderBox( Spider ):
    args = [
        _( "mrc_file", type="file", ext="mrc" ),
        _( "map_file", type="file", ext="cpv" ),
        _( "pdb_file", type="file", ext="pdb" ),
        _( "res1", type="sele", help="resno:chain, i.e. 10:A" ),
        _( "res2", type="sele" ),
        _( "length", type="int", range=[1, 30] ),
        #_( "pixelsize", type="slider", range=[1, 10], fixed=True ),
        _( "resolution", type="float", range=[1, 10],
            help="of the map_file" )
    ]
    out = [
        _( "var_file", file="variables.cpv" ),
        _( "box_file", file="ergebnisse.cpv" ),
        _( "box_map_file", file="boxil.cpv" )
    ]
    script_tmpl = "box.spi"
    def _init( self, *args, **kwargs ):
        super(SpiderBox, self)._init( "__tmpl__" )
    def _pre_exec( self ):
        boxsize=getMrc(self.mrc_file,'nx' )
        size=getMrc(self.mrc_file,'xlen' )
        pixelsize=(size/boxsize)
        coords1, coords2 = self._get_coords( 
            self.pdb_file, self.res1, self.res2 
        )
        self._make_variables_file(
            coords1, coords2, self.length, pixelsize, self.resolution
        )
        self._make_script_file( 
            map_name=self.relpath( self.map_file, no_ext=True ), 
            var_name=self.relpath( self.var_file, no_ext=True )
        )
    def _get_coords( self, pdb_file, res1, res2 ):
        npdb = NumPdb( pdb_file )
        return npdb.center( **res1 ), npdb.center( **res2 )
    def _make_variables_file( self, coords1, coords2, length, 
                              pixelsize, resolution ):
        variables = "1 9 %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %i %4.2f %4.2f" % (
            coords1[0], coords1[1], coords1[2],
            coords2[0], coords2[1], coords2[2],
            length, pixelsize, resolution
        )
        with open( self.var_file, "w" ) as fp:
            fp.write( variables )
Example #21
0
class PdbAssembly( PyTool ):
    args = [
        _( "pdb_id", type="str", 
            help="pdb id" )
    ]
    out = [
        _( "assembly_file", file="assembly.pdb" )
    ]
    def func( self ):
        try:
            data = pdb_assembly( self.pdb_id )
        except:
            # if assembly download fails there is probably no assembly
            # so download the standard pdb file
            data = pdb_download( self.pdb_id )
        with open( self.assembly_file, "w" ) as fp:
            fp.write( data )
Example #22
0
class SpiderSidechainCorrelation ( Spider ):
    args = [
        _( "map_file", type="file", ext="cpv" ),
        _( "pdb_file", type="file", ext="pdb" ),
        _( "pixelsize", type="float", range=[0, 10] ),
        _( "resolution", type="float", range=[0, 10] ),
        _( "residue", type="int", range=[0, 999] ),
        _( "chain", type="str" )
    ]
    out = [
        _( "sidechain_dir", dir="rotamere" ),
        _( "sccrosscorrel_file", file="sccrosscorrelation.cpv" ),
        _( "crosscorrel_json", file="crosscorrelation.json" )
    ]
    script_tmpl = "sidechaincc.spi"

    def _init( self, *args, **kwargs ):
        super(SpiderSidechainCorrelation, self)._init( "__tmpl__" )

    def _pre_exec( self ):
        npdb=NumPdb( self.pdb_file )
        sele={"resno": self.residue, "chain": self.chain}
        resname1=npdb.get('resname', **sele)[0]
        num_rota=get_rotno(resname1)
        coords=self._get_ca(self.pdb_file,self.chain, self.residue)
        print "huh" ,coords [0] [0]

        x_ca= coords[0] [0]
        y_ca=coords [0][1]
        z_ca=coords [0] [2]
        self._make_script_file(
            resolution=self.resolution,
            pixelsize=self.pixelsize,
            map_name=self.relpath( self.map_file, no_ext=True ),
            x_ca=x_ca ,
            y_ca=y_ca,
            z_ca=z_ca,
            cc_dir=self.relpath( self.sidechain_dir ) + os.sep,
            num_rota=num_rota,
            resname1=self.relpath (self.sidechain_dir)+ os.sep+resname1,
            residue=self.residue
            )
        MakeAllRotameres(self.pdb_file, self.chain,self.residue,zfill=2,output_dir=self.sidechain_dir)

    def _get_ca (self,pdb_file,chain, residue):
        npdb=NumPdb( pdb_file )
        sele1={"resno": self.residue, "chain": self.chain}
        resname1=npdb.get('resname', **sele1)[0]
        sele={"resno": residue, "chain": chain, "resname": resname1 ,"atomname":'CA'}
        cacoord=npdb.get('xyz',**sele)
        return cacoord
Example #23
0
class PdbUnzip( PyTool ):
    args = [
        _( "pdb_archive", type="dir" )
    ]
    def func( self ):
        pdb_file_list = get_pdb_files( self.pdb_archive, pattern="ent.gz" )
        for pdb_file in pdb_file_list:
            unzip_pdb( pdb_file )
Example #24
0
class PdbtmDownload( PyTool ):
    """A tool to download the Pdbtm database"""
    out = [
        _( "pdbtm_xml", file="pdbtm.xml" )
    ]
    def func( self ):
        with open( self.pdbtm_xml, "w" ) as fp:
            fp.write( pdbtm_download() )
Example #25
0
class OptimizeRotamer ( PyTool ):
    args = [
        _("result_direc",type="str")
    ]
    out = [
        _( "verybestrotamers", file="verybestrotamers.pdb" )
    ]
        
    def  _init( self , *args, **kwargs ):
        self.bestbuild=BuildBest(self.result_direc)
    def func (self):
        self.bestbuild()
        npdb=NumPdb( "bestrotamers.pdb" )
        
        a=True
        z=2
        #while a==True:
        clashes,a=find_all_clashes(npdb)
        gtree=get_tree(npdb['xyz'])
        print clashes
        for i in clashes:
            localresi=[]
            #hole CA atom vom ersten clashpartner 
            r=npdb.sele(resno=i[0],atomname='CA')
            p=npdb.get('xyz',sele=r)
            #indices im 6 A umkreis um den clash
            l=gtree.query_ball_point(p,6)
            print l[0]
            #aus den indices eine liste mit residuname und nummer machen
            for x in l[0]:
                a=npdb.get('resname')[x]
                b=npdb.get('resno')[x]
                c=npdb.get('chain')[x]
                localresi.append([b,a,c])
            localresi=sorted(localresi)
            localresi=list(localresi for localresi,_ in itertools.groupby(localresi))
            #print localresi
            for index,i in enumerate (localresi):
                if i[1] not in ('ALA','GLY'):
                    rotadir="%s_%s_%i" % (i[2],i[1],i[0])
                    ccsortpath=os.path.join(self.result_direc,rotadir)
                    ccsort="%s/%s" % (ccsortpath,'ccsort.cpv')
                    print ccsortpath
                    
            break
Example #26
0
class MrcHeaderPrinter( PyTool ):
    args = [
        _( "mrc_file", type="file", ext="mrc" )
    ]

    def func( self, *args, **kwargs ):
        header = mrc_header( self.mrc_file )
        for name, value in zip(header._fields, header):
            print "%20s\t%s" % ( name, value )
Example #27
0
class MppdStats(PyTool):
    args = [_("mppd_file", type="file", ext="json")]

    def _init(self, *args, **kwargs):
        pass

    def func(self):
        records = JsonBackend(self.mppd_file, MppdRecord)
        print len(records)
Example #28
0
class VoronoiaStats(PyTool):
    args = [_("voronoia_file", type="file", ext="json")]

    def _init(self, *args, **kwargs):
        pass

    def func(self):
        records = JsonBackend(self.voronoia_file, VoronoiaRecord)
        print len(records)
Example #29
0
class PdbtmInfo( PyTool ):
    """A tool to get infos from the PDBTM database"""
    args = [
        _( "pdb_id", type="str" ),
    ]
    out = [
        _( "info_file", file="pdbtm_info_{pdb_id}.json" )
    ]
    def _init( self, *args, **kwargs ):
        pass
    def func( self ):
        self.info = pdbtm_info( self.pdb_id )
        with open( self.info_file, "w" ) as fp:
            json.dump( self.info, fp, indent=4 )
    def get_info( self ):
        if not hasattr( self, "info" ):
            with open( self.info_file, "r" ) as fp:
                self.info = json.read( fp )
        return self.info
Example #30
0
class PdbtmList( PyTool ):
    args = [

    ]
    out = [
        _( "list_file", file="pdbtm_list.json" )
    ]
    def func( self ):
        list_record = pdbtm_list()
        ListIO( self.list_file ).write( list_record )