예제 #1
0
 def test_pdb_code(self):
     self.assertTrue(gemmi.is_pdb_code('9ALA'))
     self.assertFalse(gemmi.is_pdb_code('BAD1'))
     pdb_dir = os.getenv('PDB_DIR')
     if not pdb_dir:
         return
     cif_4xyz = pdb_dir + '/structures/divided/mmCIF/xy/4xyz.cif.gz'
     self.assertEqual(gemmi.expand_pdb_code_to_path('4XYZ', 'M'), cif_4xyz)
     self.assertEqual(gemmi.expand_if_pdb_code('4XYZ'), cif_4xyz)
     self.assertEqual(gemmi.expand_if_pdb_code('4XYZ', filetype='P'),
                      pdb_dir + '/structures/divided/pdb/xy/pdb4xyz.ent.gz')
예제 #2
0
파일: aafreq.py 프로젝트: sizmailov/gemmi
def get_file_paths_from_args():
    for arg in sys.argv[1:]:
        if os.path.isdir(arg):
            for path in CifWalk(arg):
                yield path
        else:
            yield expand_if_pdb_code(arg)
예제 #3
0
def get_file_paths_from_args():
    """\
    Process arguments as filenames or directories with .cif(.gz) files,
    and yield the file paths.
    Normally we first test our scripts on a few files:
      ./myscript 1mru.cif another.cif
    and then do pdb-wide analysis:
      ./myscript $PDB_DIR/structures/divided/mmCIF
    If $PDB_DIR is set you can check the specifies PDB entries:
      ./myscript 1ABC 2def
    If you have a list of PDB codes to analyze (one code per line, the code
    must be the first word, but may be followed by others), do:
      ./myscript --only=my-list.txt $PDB_DIR/structures/divided/mmCIF
    """
    parser = argparse.ArgumentParser(usage='%(prog)s [options] path [...]')
    parser.add_argument('path', nargs='+', help=argparse.SUPPRESS)
    parser.add_argument('--only',
                        metavar='LIST',
                        help='Use only files that match names in this file')
    args = parser.parse_args()
    only = None
    if args.only:
        with open(args.only) as list_file:
            only = set(line.split()[0].lower() for line in list_file
                       if line.strip())
    for arg in args.path:
        if os.path.isdir(arg):
            for root, dirs, files in os.walk(arg):
                dirs.sort()
                for name in sorted(files):
                    for ext in ['.cif', '.cif.gz']:
                        if name.endswith(ext):
                            if not only or name[:-len(ext)].lower() in only:
                                yield os.path.join(root, name)
                                break
        else:
            yield expand_if_pdb_code(arg)
예제 #4
0
def main():
    if len(sys.argv) < 2:
        sys.exit('Specify files, directories or PDB codes.')
    for arg in sys.argv[1:]:
        for path in gemmi.CoorFileWalk(gemmi.expand_if_pdb_code(arg)):
            check_mtrix_rot(path)