Exemple #1
0
 def test_1(self):
     """Formatlib: second test"""
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test1.in'))
     pdb_file.pedantic_pdb()
     result = pdb_file.pdb_string
     f = open(os.path.join(DIRNAME, 'test1.out'))
     correct = f.read()
     f.close()
     self.assertEqual(correct, result)
Exemple #2
0
 def test_0(self):
     """Formatlib: first test"""
     tmpfile = os.path.join(tempdir or '/tmp/', str(uuid.uuid4()))
     shutil.copyfile(os.path.join(DIRNAME, 'test0.in'), tmpfile)
     pdb_file = PDBFile(pdb_path=tmpfile)
     pdb_file.pedantic_pdb()
     result = pdb_file.pdb_string
     os.remove(tmpfile)
     f = open(os.path.join(DIRNAME, 'test0.out'))
     correct = f.read()
     f.close()
     self.assertEqual(correct, result)
Exemple #3
0
def rebuild_full_atom(input_pdb, output_pdb):
    """Make all atom PDB file from 3 atom PDB file

    Arguments:
      * input_pdb = path to input PDB
      * output_pdb = path to output PDB
    """
    try:
        old_pwd = os.getcwd()
        print old_pwd
    except:
        old_pwd = None
    tempdir = mkdtemp()
    os.chdir(tempdir)
    try:
        os.symlink(REBUILDRNA_PATH + os.sep + 'histograms', 'histograms')
        os.symlink(REBUILDRNA_PATH + os.sep + 'pdb', 'pdb')
    except OSError:
        pass
    # remove strange residue names
    pdb_file = PDBFile(pdb_path=os.path.join(old_pwd, input_pdb))
    pdb_file._resname_3to1()
    pdb_file.save(os.path.join(tempdir, input_pdb))
    cmd = Popen([REBUILDRNA_PATH + os.sep + 'RebuildRNA',
        '-t', os.path.join(tempdir, input_pdb), '-o', tempdir])
    returncode = cmd.wait()
    out_name = tempdir + os.sep +\
        '.'.join(os.path.basename(input_pdb).split('.')[:-1]) + '_beforeCorrecting.pdb'
    os.rename(out_name, output_pdb)
    try:
        if old_pwd:
            os.chdir(old_pwd)
        rmtree(tempdir)
    except OSError:
        pass
    return returncode
Exemple #4
0
    else:
        print("\nNeed to provide at least an output type.\n")
        sys.exit(0)

except:

    print("\nFailed to process input\n")
    printhelp()
    sys.exit(0)




########################################################################
##PARSE
pdb = PDBFile(filepath=filename)
pdb.parametersParse()
############################################################################

def remove_model_tags(filepath):
    #remove model references
    print("Removing MODEL references for Coot....")
    file = open(outputfile,"r")
    lines = file.readlines()
    newlines = []
    for line in lines:
        if ("MODEL" not in line) and ("ENDMDL" not in line) :
            newlines.append(line)
        else:
            print("Removing MODEL entry "+line)
    file.close()
Exemple #5
0
 def test_resname_check_and_1to3(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test0.in'))
     pdb_file.resname_check_and_3to1()
     with open(os.path.join(DIRNAME, 'test0_3to1.out')) as f:
         correct = f.read()
     self.assertEqual(pdb_file.pdb_string, correct)
Exemple #6
0
 def test_remove_non_atoms(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test_nmr.in'))
     pdb_file.remove_non_atoms()
     with open(os.path.join(DIRNAME, 'test_nmr_atom.out')) as f:
         correct = f.read()
     self.assertEqual(pdb_file.pdb_string, correct)
Exemple #7
0
 def test_get_fasta(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test0.in'))
     self.assertEqual(pdb_file.get_fasta(name='test'), '>test\nGAGCCGUAUGCGAUGAAAGUCGCACGUACGGUUC\n')
Exemple #8
0
 def test_seq_from_pdb(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test0.in'))
     self.assertEqual(pdb_file.seq_from_pdb(), 'GAGCCGUAUGCGAUGAAAGUCGCACGUACGGUUC')
Exemple #9
0
 def test_detect_proteins(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'protein.pdb'))
     self.assertTrue(pdb_file.detect_proteins())
Exemple #10
0
 def test_validate_pdb_false(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test.py'))
     self.assertFalse(pdb_file.validate_pdb())
Exemple #11
0
 def test_validate_pdb_true(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test0.in'))
     self.assertTrue(pdb_file.validate_pdb())
Exemple #12
0
 def test_check_and_get_first_model(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test_nmr.in'))
     pdb_file.check_and_get_first_model()
     with open(os.path.join(DIRNAME, 'test_nmr.out')) as f:
         correct = f.read()
     self.assertEqual(pdb_file.pdb_string, correct)
Exemple #13
0
 def test_count_models(self):
     pdb_file = PDBFile(pdb_path=os.path.join(DIRNAME, 'test_nmr.in'))
     self.assertEqual(pdb_file.count_models(), 10)