Example #1
0
 def _getligprop(self, filename):
     """ calculate basic properties from PDBQT ligand
         mw, hba, hbd, heavy atoms
     """
     try:
         lines = hf.getLines(filename)
         atoms = hf.getAtoms(lines)
     except:
         return False, sys.exc_info()[1]
     if len(lines) == 0:
         return False, "empty file"
     if len(atoms) == 0:
         return False, "no atoms (INVALID FILE)"
     try:
         tors = int(lines[-1].split()[1])
     except:
         return False, "no torsions (INVALID FILE)"
     # hb
     hba, hbd = [ len(x) for x in  hf.findHbAccepDon(atoms) ]
     # atypes ( report all types with duplicates, to be used for updating lib types)
     atypes = list(set([ x.split()[-1] for x in atoms ]))
     # heavy
     heavy = len([ x for x in atypes if not x == 'HD' ])
     # mw
     mw = 0
     for a in atypes:
         mw += hf.adtypes.get( a, [None,0])[1]
     return True, {'tors' : tors, 'heavy' : heavy, 'mw' : mw, 'hba' : hba, 'hbd': hbd, 'atypes': atypes }
Example #2
0
 def writeLogJson(self, logname, compression = False):
     """ write log in json format
     """
     if not len(self.results.keys()):
         print "cowardly refusing to write an empty file"
         return
     hf.writejson(logname, self.results, compression)
Example #3
0
 def upload(self, dirname=None, destpath=None, autoregister=False, overwrite=False, bg=False):
     """upload the library to the remote server $dest path"""
     if dirname == None:
         dirname = hf.validFilename(self.name())
     if dirname == '':
         dirname = 'libdir'
         self.dprint("warning: lib dirname empty, providing substutute [%s]" % libdir)
     if destpath == None:
         destpath == self.server.getLibraryPath()
     if (self.server == None) or (self.server == 'localhost'):
         self._localcopy( dirname, destpath, autoregister, overwrite, bg)
     else:
         self._remotecopy( dirname, destpath, autoregister, overwrite, bg)
     self.updatestatus()
Example #4
0
 def updateDownloadBigFile(self):
     """ update download status of big files transfers"""
     if self.checkPending() == False:
         return 100.00
     #self._counter
     try:
         self.dprint("checking local size of [%s]" % self._localfile)
         curr_size = os.stat(self._localfile).st_size
         self.dprint(' found %s' % curr_size)
     except:
         self.dprint('file checking error [%s]' % sys.exc_info()[1] )
         curr_size = 0
     pc = hf.percent(curr_size, self._total)
     self.dprint("current size [%d/%d] : %2.3f%%" % (curr_size, self._total, pc) )
     return pc
Example #5
0
 def updateDownloadBigFile(self):
     """ update download status of big files transfers"""
     if self.checkPending() == False:
         return 100.00
     #self._counter
     try:
         self.dprint("checking local size of [%s]" % self._localfile)
         curr_size = os.stat(self._localfile).st_size
         self.dprint(' found %s' % curr_size)
     except:
         self.dprint('file checking error [%s]' % sys.exc_info()[1])
         curr_size = 0
     pc = hf.percent(curr_size, self._total)
     self.dprint("current size [%d/%d] : %2.3f%%" %
                 (curr_size, self._total, pc))
     return pc
Example #6
0
    def _remotecopy(self, dirname, destpath, autoregister=False, overwrite=False, bg=True):
        """ perform the copy on remote path"""
        # generating fullpath
        self.path = destpath + '/' + dirname
        if self.server.ssh.exists(self.path):
            self.dprint('remote library dirname[%s] exist in the path[%s] => [%s]...' % (dirname, destpath, self.path))
            if not overwrite:
                self.dprint('overwrite not allowed, returning')
                return
            else:
                self.server.ssh.remove([self.path])

        # update the ligand destination with split_path
        step = self.options['split']
        items = sorted(self.items.keys())
        total = len(items)
        if (not step == None) and (step <= total):
            count = 0
            for i in items:
                self.dprint("updating splitted name [%s] =>" % self.items[i]['fullpath']),
                self.items[i]['fullpath'] = '/'.join([hf.splitdir(count, total, step),
                            self.items[i]['fullpath']])
                self.dprint("[%s]" % self.items[i]['fullpath'])
                count+=1
        transfer_list = []
        for i in items:
            dest = '/'.join([dirname, self.items[i]['fullpath'] ])
            transfer_list.append( [self.items[i]['source'], dest])
        # transfer files
        mule = self.server.transfer
        self.dprint("starting the transfer with the mule[%s]" % mule)
        mule.upload(files = transfer_list, remotedestpath=destpath, bg=bg)
        self.dprint("mule started... ongoing...")

        if autoregister:
            if not bg:
                libindex = self.path + '/' + 'library.db'
                self.saveIndex(libindex)
                self.registerLibrary(overwrite)
            else:
                print "AUTOREGISTER DISABLED! BACKGROUND UPLOAD (TO FIX)"