Esempio n. 1
0
 def test_writer_1(self):
     """
     Checks that MMCIFParser can read the file written by MMCIFWriter
     """
     parser = MMCIFParser(filename='Data/1CRN.cif')
     mol = parser.parse()
     writer = MMCIFWriter()
     writer.write('Data/1CRN_.cif',mol)
     new_parser = MMCIFParser(filename='Data/1CRN_.cif')
     mol = parser.parse()
     os.remove('Data/1CRN_.cif')
 def test_writer_1(self):
     """
     Checks that MMCIFParser can read the file written by MMCIFWriter
     """
     parser = MMCIFParser(filename='Data/1CRN.cif')
     mol = parser.parse()
     writer = MMCIFWriter()
     writer.write('Data/1CRN_.cif', mol)
     new_parser = MMCIFParser(filename='Data/1CRN_.cif')
     mol = parser.parse()
     os.remove('Data/1CRN_.cif')
 def test_write_2(self):
     """
     Tests that PdbWriter can write molecule parsed by MMCIFParser
     """
     # read a molecule
     parser = MMCIFParser(filename='Data/1CRN.cif')
     mol = parser.parse()
     # instanciate a PdbWriter and call the write method with the
     # default arguments
     from MolKit.pdbWriter import PdbWriter
     writer = PdbWriter()
     writer.write('Data/1crn_mmcifwriter.pdb', mol)
     os.remove('Data/1crn_mmcifwriter.pdb')
Esempio n. 4
0
 def test_write_2(self):
     """
     Tests that PdbWriter can write molecule parsed by MMCIFParser
     """
     # read a molecule
     parser = MMCIFParser(filename='Data/1CRN.cif')
     mol = parser.parse()
     # instanciate a PdbWriter and call the write method with the
     # default arguments
     from MolKit.pdbWriter import PdbWriter
     writer = PdbWriter()
     writer.write('Data/1crn_mmcifwriter.pdb', mol)
     os.remove('Data/1crn_mmcifwriter.pdb')
Esempio n. 5
0
                file_out.write("HETATM")
            file_out.write(" %6s" % Atom.number)  #2
            file_out.write(" " + Atom.element)  #3
            file_out.write(" %5s" % Atom.name)  #4
            file_out.write(" " + Atom.parent.type)  #5
            if Atom.parent.parent.name == ' ':
                file_out.write(" ?")  #6
            else:
                file_out.write(" " + Atom.parent.parent.name)
            file_out.write(" %5d" % int(Atom.parent.number))  #7
            file_out.write(" %7.3f" % Atom._coords[0][0])  #8
            file_out.write(" %7.3f" % Atom._coords[0][1])  #9
            file_out.write(" %7.3f" % Atom._coords[0][2])  #10
            file_out.write(" %6.2f" % float(Atom.occupancy))  #11
            file_out.write(" %6.2f" % float(Atom.temperatureFactor))  #12
            file_out.write("\n")
        file_out.close()


if __name__ == '__main__':
    from MolKit.mmcifParser import MMCIFParser
    parser = MMCIFParser(filename='Tests/Data/1CRN.cif')
    print "Reading molecule"
    mol = parser.parse()
    print "Done parsing"
    SS_Data = parser.parseSSData(mol)
    print "Done parsing secondary structure"
    writer = MMCIFWriter()
    writer.write('Tests/Data/1CRN_.cif', mol)
    print "Done"
Esempio n. 6
0
            else:
                file_out.write("HETATM")
            file_out.write(" %6s"%Atom.number)                      #2
            file_out.write(" " + Atom.element)                      #3
            file_out.write(" %5s"%Atom.name)                        #4
            file_out.write(" " + Atom.parent.type)                  #5
            if Atom.parent.parent.name == ' ':
                file_out.write(" ?")                                #6
            else:
                file_out.write(" " + Atom.parent.parent.name)
            file_out.write(" %5d"%int(Atom.parent.number))          #7
            file_out.write(" %7.3f"%Atom._coords[0][0])             #8
            file_out.write(" %7.3f"%Atom._coords[0][1])             #9
            file_out.write(" %7.3f"%Atom._coords[0][2])             #10
            file_out.write(" %6.2f"%float(Atom.occupancy))          #11
            file_out.write(" %6.2f"%float(Atom.temperatureFactor))  #12
            file_out.write("\n")
        file_out.close()

if __name__ == '__main__':
    from MolKit.mmcifParser import MMCIFParser
    parser = MMCIFParser( filename='Tests/Data/1CRN.cif' )
    print "Reading molecule"
    mol = parser.parse()
    print "Done parsing"
    SS_Data  = parser.parseSSData( mol )
    print "Done parsing secondary structure"
    writer = MMCIFWriter()
    writer.write('Tests/Data/1CRN_.cif',mol)
    print "Done"
 def test_parseNAD(self):
     parser1 = MMCIFParser("Data/1GGA_.cif")
     mol1 = parser1.parse()
     P = mol1.chains[-1].residues.atoms[0].chemElem
     assert P is 'P' 
 def test_parseFileWrongFormat(self):
     parser1 = MMCIFParser("Data/fakePDB.pdb")
     mols1 = parser1.parse()
     assert mols1 is None or len(mols1)==0
 def test_parseSSData(self):
     """Check that parseSSData() parses secondary structure"""
     parser1 = MMCIFParser(filename='Data/1CRN.cif')
     mols1 = parser1.parse()
     ssDataForMol = parser1.parseSSData(mols1)   
 def initParser(self):
     global mols
     if mols is None:
         parser = MMCIFParser(filename='./Data/2PLV.cif')
         mols = parser.parse()
     self.mols = mols