def loadScop(self, cla_path=None, des_path=None, hie_path=None): if cla_path is None: self.cla_file = file(parms.get('scopClassification'), 'r') self.des_file = file(parms.get('scopDescription'), 'r') self.hie_file = file(parms.get('scopHierarchy'), 'r') elif cla_path is not None and hie_path is not None and des_path is not None: self.cla_file = file(cla_path, 'r') self.des_file = file(des_path, 'r') self.hie_file = file(hie_path, 'r') else: print "Error in arguments" return self.ScopStructure = SCOP.Scop(self.cla_file, self.des_file, self.hie_file) self.ScopDomains = self.ScopStructure.getDomains() cla_file_name = self.cla_file.name if self.isAprofile == 1: self.profileName = cla_file_name[ cla_file_name[:cla_file_name.rindex('\\')].rindex('\\') + 1:cla_file_name.rindex('\\')] self.profileSunid = cla_file_name[cla_file_name.rindex('\\') + 1:cla_file_name.rindex('\\') + 6] print "Profile Name: " + self.profileName
def copyPDBs(self, savePath): cla = file(self.saveResultsin+str(self.currentSelection.thisNode.sunid)+"_cla.txt", 'r') hie = file(self.saveResultsin+str(self.currentSelection.thisNode.sunid)+"_hie.txt", 'r') des = file(self.saveResultsin+str(self.currentSelection.thisNode.sunid)+"_des.txt", 'r') scopStruct = SCOP.Scop(cla, des, hie) domsStruct = scopStruct.getDomains() for eachItem in domsStruct: hierarchy = [] curItem = eachItem """ This loop creates a list of directories need to save the domain Eg: If the node hierarchy is of the form Globin->Globin_child->Globin_child_child->Globin_child_child_child and 'Globin_child_child_child' is selected then the list hierarchy will contain [Globin, Globin_child, Globin_child_child, Globin_child_child_child] """ while curItem is not None: name = self.filterFoldername(curItem.description) #If the length of the node.description is > 20, the pad the end of it #with its sunid if len(name)>20: name = name[:20]+'_'+curItem.sunid hierarchy.append(name.strip()) if self.currentSelection.thisNode.sunid.find(curItem.sunid) == 0: curItem = None else: curItem = curItem.parent curPath = savePath #From the 'hierarchy' list, from top down, each item is checked to see if the #folder exists by that name. If it doesnot exist, the folder structure is created. #If the folder by that name exists, then the next item in the 'heirarchy' list is checked while len(hierarchy) > 0: foldr = hierarchy.pop() curPath = curPath+'\\'+foldr if not path.isdir(curPath): mkdir(curPath) while len(hierarchy) > 0: curPath = curPath + '\\' + hierarchy.pop() mkdir(curPath) scopPdbsLoc = parms.get('scopPDBsLocation') #Copy the .ent file from the SCOP Database to the current profile location if path.isdir(scopPdbsLoc+eachItem.sid[2:4]) and path.isfile(scopPdbsLoc+eachItem.sid[2:4]+'\\'+eachItem.sid+'.ent'): copy(scopPdbsLoc+eachItem.sid[2:4]+'\\'+eachItem.sid+'.ent', curPath+'\\'+eachItem.sid+'.ent') else: print "Protein Domain: "+eachItem.sid+" doesnot exist!"
def getAllNodes(self): files = listdir(self.dirpath) for item in files: if re.compile('\d\d\d\d\d_hie.txt').match(item): if path.isfile(self.dirpath+item[:5]+'_des.txt') and path.isfile(self.dirpath+item[:5]+'_cla.txt'): self.nodesNames.append(item[:5]) clasi = file(self.dirpath+item[:5]+'_cla.txt', 'r') descr = file(self.dirpath+item[:5]+'_des.txt', 'r') hiera = file(self.dirpath+item[:5]+'_hie.txt', 'r') self.nodesScop.append(SCOP.Scop(clasi, descr, hiera)) self.domainsScop.append(self.nodesScop[len(self.nodesScop)-1].getDomains()) descr.seek(0) self.nodesScop[len(self.nodesScop)-1].root.description = descr.readline().split('\t').pop().strip()+'_'+item[:5] hiera.seek(0) line = hiera.readline() lineage = [] while line[0] == '#': lineage.append(line[1:].strip()) line = hiera.readline() lineage.reverse() self.nodesLineage.append(lineage)
def test_search(self): """Bio.SCOP.search(...)""" handle = SCOP.search("1JOY")
def test_search(self): """Test search.""" handle = SCOP.search("1JOY")
def updateClaList(self, nde, cla): if len(nde.children) == 0: if self.currentNodeClaList.count(nde.sunid) == 0: self.currentNodeClaList.append(nde.sunid) cla.write(self.entireClaList[nde.sunid]) #Builds a hashed list with the sunids as keys from the classification file def buildClaList(self): fullFile = file(parms.get('scopClassification'), 'r').readlines() rex = re.compile('\t\d\d\d\d\d\t') for line in fullFile: a = rex.search(line) if a: self.entireClaList[a.group().strip()] = line #else: # print "Unable to index the line: "+line if __name__ == '__main__': main_window = Tk() clasi = file(parms.get('scopClassification'), 'r') descr = file(parms.get('scopDescription'), 'r') heira = file(parms.get('scopHierarchy'), 'r') scopStruct = SCOP.Scop(clasi, descr, heira) a = SearchFrame(main_window, scopStruct.root) a.mainloop()
def __init__(self, parent, viewer, menSystem): Frame.__init__(self, parent.pane('top'), bg='white') self.focus() self.nodesList = [ ] #List of all the nodes in the treeWinText textbox. (has ScopNode objects) self.currentNodeClaList = [ ] #Temp. variable used in UpdateCla funciton self.entireClaList = { } #Classification file is parsed and all domains are hashed by their sids #The bottom pane in the viewer represents the Molecular Viewer self.molnir_level = parent.pane('bottom') self.viewer_window = viewer self.topMenuSystem = menSystem self.saveResultsin = "" #directory path set by the user to save the profile self.currentProfileName = "" self.profilesPath = parms.get('profilesPath') self.type = parms.get('classifications_fullname') #Open the SCOP Parseable Text files clasi = file(parms.get('scopClassification'), 'r') descr = file(parms.get('scopDescription'), 'r') heira = file(parms.get('scopHierarchy'), 'r') #Load SCOP Structure and SCOP Domains self.scopDataStruct = SCOP.Scop(clasi, descr, heira) self.domains = self.scopDataStruct.getDomains() self.nameHierarchy = parms.get('nameHierarchy') self.pdbPath = "" self.balloon = Pmw.Balloon(self) self.menuBar = Pmw.MenuBar(self, hull_relief=RAISED, hull_borderwidth=1, balloon=self.balloon) self.menuBar.pack(fill=X, expand=NO, anchor=N) self.menuBar.addmenu('Profiles', 'Search Profiles') self.menuBar.addmenuitem('Profiles', 'command', command=self.loadProfile, label='Load Profile') self.menuBar.addmenuitem('Profiles', 'command', command=self.editProfile, label='Edit Profile(s)') self.menuBar.addmenu('Save', 'Create a local DB Structure') self.menuBar.addmenuitem('Save', 'command', command=self.saveSelectedNode, label='Save selected Node as a Profile') self.menuBar.addmenu('Search', 'Search Entire SCOP Database') self.menuBar.addmenuitem('Search', 'command', command=self.loadSCOPSearch, label='Search SCOP') self.treeWinText = Pmw.ScrolledText(self, labelpos='n', usehullsize=1, label_text='SCOP Domain Viewer', hull_width=100, hull_height=20, text_padx=1, text_pady=1, text_wrap='none', text_cursor='arrow') self.treeWinText.pack(side=LEFT, expand=YES, fill=BOTH) self.pack(expand=YES, fill=BOTH) self.lineageBox = Text(self, relief=FLAT, cursor="arrow") self.lineageBox.pack(side=TOP, anchor=N) self.lineageBox.config(height=12, width=38, state=DISABLED) self.viewButton = Button(self, text="View", state=DISABLED, height=1, command=self.displaySelected, width=5) self.viewButton.pack(side=LEFT, anchor=S, padx=10) self.lines = 1 #Load all the toplevel nodes (all of type 'Class') into the textbox for item in self.scopDataStruct.root.children: self.nodesList.append(ScopNode(item, self)) indx = "%0.1f" % (self.lines) self.treeWinText.window_create( indx, window=self.nodesList[len(self.nodesList) - 1]) indx = "%0.1f" % (self.lines + 0.1) self.treeWinText.insert(indx, '\n') self.lines = self.lines + 1 #self.currentSelection is updated everytime when a user clicks on a Node in the treeWinText text box self.currentSelection = self.nodesList[0] self.treeWinText.pack() self.treeWinText.configure(text_state='disabled') self.pack()