def deleteChain():# Delete a complete chain from a pdb and save the new structure in pdbname_free.pdb parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() seq='' nb_chain=input('How many chain do you want to delete : ') for i in range(nb_chain): rm_chain=raw_input('What chain you want to delete : ') for model in structure: for chain in model: if(chain.id==rm_chain): model.detach_child(chain.id) pept = raw_input('Do you want to get a pdb with the sequence in its name : ') if(pept == 'y'): ppb=PPBuilder() for pp in ppb.build_peptides(structure): seq = seq + pp.get_sequence() seq=seq.lower() seq=str(seq) w = PDBIO() w.set_structure(structure) w.save(seq+'_bound.pdb') else: w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_without'+rm_chain+'.pdb')
def get_info(filename): ''' Return header. Function adapted from Biopython Package.\n get_info(filename)\n Filename needs to be a PDB file format (*.ent or *.pdb) ''' p = PDBParser(QUIET=True) s = p.get_header()
def removeDoubleAtoms():# Remove all double atoms defined in a pdb and save the new structure in pdbname_noDouble.pdb parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() structure.remove_disordered_atoms() w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_noDouble.pdb')
def renameChain(): parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() what_chain=raw_input('What is the chain you want to rename : ') what_chain2=raw_input('What is the new name of this chain : ') for model in structure: for chain in model: if chain.id == what_chain: chain.id = what_chain2 w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_rename.pdb')
def removeHetero():# Remove all heteroatoms from a pdb and save the new structure in pdbname_noHetero.pdb parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() for model in structure: for chain in model: for residue in chain: id = residue.id if id[0] != ' ': chain.detach_child(residue.id) if len(chain) == 0: model.detach_child(chain.id) w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_noHetero.pdb')
def deleteResidue():# Delete a residue from a pdb and save the new structure in pdbname_noResidue.pdb parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() rm_residue=raw_input('What residue you want to delete : ') for model in structure: for chain in model: for residue in chain: print residue.id if(residue.id[1]==rm_residue): print 'HELLO' chain.detach_child(residue.id) w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_noResidue.pdb')
def getSequence(): # Get the sequence of a specific chain parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() seq='' what_chain=raw_input('For what chain do you want the sequence : ') for model in structure: for chain in model: if chain.id != what_chain: model.detach_child(chain.id) ppb=PPBuilder() for pp in ppb.build_peptides(structure): seq = seq + pp.get_sequence() seq=seq.lower() print seq
def getSequence(): # Get the sequence of a specific chain parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() seq='' what_chain=raw_input('For what chain do you want the sequence : ') for model in structure: for chain in model: if chain.id != what_chain: model.detach_child(chain.id) ppb=PPBuilder() for pp in ppb.build_peptides(structure): seq = seq + pp.get_sequence() seq=seq.upper() print seq
def assembleChain(): # Allow to assemble 2 chains together parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() what_chain=raw_input('What is the 1st chain you want to assemble : ') what_chain2=raw_input('What is the 2nd chain you want to assemble : ') for model in structure: for chain in model: if chain.id == what_chain: parent=chain; elif chain.id == what_chain2: for residue in chain: residue.get_parent().id=what_chain w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_assemble.pdb')
def renumberChain(): # Allow to renumber from what you want a specific chain parser = PDBParser() nameStruct=pdb_name.partition('.')[0] structure = parser.get_structure(nameStruct, pdb_name) header = parser.get_header() trailer = parser.get_trailer() what_chain=raw_input('What is the chain you want to renumber : ') number=input('What is the first number of the chain : ') for model in structure: for chain in model: if chain.id == what_chain: for residue in chain: if residue.id[0] == ' ': residue.id=(' ', number, ' ') number=number+1 else: chain.detach_child(residue.id) w = PDBIO() w.set_structure(structure) w.save(nameStruct+'_ren.pdb')
def shannon_entropy_list_msa(alignment_file): shannon_entropy_list = [] for col_no in xrange(len(list(alignment_file[0]))): list_input = list(alignment_file[:, col_no]) shannon_entropy_list.append(shannon_entropy(list_input)) return shannon_entropy_list #START ACTUAL PROGRAM ############################################ #find match ############################################ #read in .pdb sequence parser = PDBParser() structure = parser.get_structure('', '1OTH.pdb') header = parser.get_header() trailer = parser.get_trailer() pdbSequence = '' for residue in structure[0]['A'].get_residues(): if (residue.get_id()[0]==' '): residueName = three_to_one(residue.get_resname()) pdbSequence += residueName #check each fasta sequence for match to pdb sequence bestMatch = '' bestScore = 0 handle = open("uniprot-ornithine+transcarbamylase-2.fasta", "rU") for record in SeqIO.parse(handle, "fasta") : foundMatch = False if foundMatch == False: tempFile = open("temp.fasta", "w") deleteContent(tempFile)