コード例 #1
0
 def test_dict2pdb(self):
     """testing pdb dict round-trip.
     """
     line = 'ATOM      1  N   MET A   1      53.045  42.225  33.724  1.00  2.75           N\n'
     d = pdb2dict(line)
     line2 = dict2pdb(d)
     assert line == line2
     d.pop('coords')
     assert d == {
         'ser_num': 1,
         'res_long_id': ('MET', 1, ' '),
         'h_flag': ' ',
         'at_name': ' N  ',
         'at_long_id': ('N', ' '),
         'bfactor': 2.75,
         'chain_id': 'A',
         'occupancy': 1.0,
         'element': ' N',
         'res_name': 'MET',
         'seg_id': '    ',
         'at_id': 'N',
         'alt_loc': ' ',
         'res_ic': ' ',
         'res_id': 1,
         'at_type': 'ATOM  '
     }
コード例 #2
0
ファイル: test_pdb.py プロジェクト: yesimon/pycogent
 def test_dict2pdb(self):
     """testing pdb dict round-trip.
     """
     line = "ATOM      1  N   MET A   1      53.045  42.225  33.724  1.00  2.75           N\n"
     d = pdb2dict(line)
     line2 = dict2pdb(d)
     assert line == line2
     d.pop("coords")
     assert d == {
         "ser_num": 1,
         "res_long_id": ("MET", 1, " "),
         "h_flag": " ",
         "at_name": " N  ",
         "at_long_id": ("N", " "),
         "bfactor": 2.75,
         "chain_id": "A",
         "occupancy": 1.0,
         "element": " N",
         "res_name": "MET",
         "seg_id": "    ",
         "at_id": "N",
         "alt_loc": " ",
         "res_ic": " ",
         "res_id": 1,
         "at_type": "ATOM  ",
     }
コード例 #3
0
ファイル: pdb.py プロジェクト: chungtseng/pycogent
def write_coords(atoms):
    old_fields = defaultdict(str)
    coords = ['MODEL        1\n']
    for atom in atoms.sortedvalues():
        fields = atom.getDict()
        if (old_fields['chain_id'] != fields['chain_id']) and old_fields['chain_id'] and old_fields['res_name'] in AA_NAMES:
                coords.append(dict2ter(old_fields))
        if (old_fields['model'] != fields['model']) and old_fields['model'] != '': # model can be 0 :)
                if old_fields['chain_id'] and old_fields['res_name'] in AA_NAMES:
                    coords.append(dict2ter(old_fields))
                coords.append('ENDMDL\n')
                coords.append('MODEL     %4i\n' % (fields['model'] + 1))
        coords.append(dict2pdb(fields))
        old_fields = fields
    if fields['res_name'] in AA_NAMES:
        coords.append(dict2ter(fields))
    coords.append('ENDMDL\n')
    coords.append('END   \n')
    return coords
コード例 #4
0
ファイル: pdb.py プロジェクト: yatisht/pycogent
def write_coords(atoms):
    old_fields = defaultdict(str)
    coords = ['MODEL        1\n']
    for atom in atoms.sortedvalues():
        fields = atom.getDict()
        if (old_fields['chain_id'] != fields['chain_id']) and old_fields['chain_id'] and old_fields['res_name'] in AA_NAMES:
                coords.append(dict2ter(old_fields))
        if (old_fields['model'] != fields['model']) and old_fields['model'] != '': # model can be 0 :)
                if old_fields['chain_id'] and old_fields['res_name'] in AA_NAMES:
                    coords.append(dict2ter(old_fields))
                coords.append('ENDMDL\n')
                coords.append('MODEL     %4i\n' % (fields['model'] + 1))
        coords.append(dict2pdb(fields))
        old_fields = fields
    if fields['res_name'] in AA_NAMES:
        coords.append(dict2ter(fields))
    coords.append('ENDMDL\n')
    coords.append('END   \n')
    return coords
コード例 #5
0
ファイル: test_pdb.py プロジェクト: GavinHuttley/pycogent
 def test_dict2pdb(self):
     """testing pdb dict round-trip.
     """
     line = 'ATOM      1  N   MET A   1      53.045  42.225  33.724  1.00  2.75           N\n'
     d = pdb2dict(line)
     line2 = dict2pdb(d)
     assert line == line2
     d.pop('coords')
     assert d == {'ser_num': 1, 'res_long_id': ('MET', 1, ' '), 
                  'h_flag': ' ', 
                  'at_name': ' N  ', 
                  'at_long_id': ('N', ' '), 
                  'bfactor': 2.75, 'chain_id': 'A', 
                  'occupancy': 1.0, 'element': ' N', 
                  'res_name': 'MET',
                  'seg_id': '    ', 'at_id': 'N', 
                  'alt_loc': ' ', 
                  'res_ic': ' ', 
                  'res_id': 1, 
                  'at_type': 'ATOM  '}
コード例 #6
0
ファイル: pdb.py プロジェクト: blankenberg/pycogent
def write_coords(atoms):
    old_fields = defaultdict(str)
    coords = ["MODEL        1\n"]
    for atom in atoms.sortedvalues():
        fields = atom.getDict()
        if (
            (old_fields["chain_id"] != fields["chain_id"])
            and old_fields["chain_id"]
            and old_fields["res_name"] in AA_NAMES
        ):
            coords.append(dict2ter(old_fields))
        if (old_fields["model"] != fields["model"]) and old_fields["model"] != "":  # model can be 0 :)
            if old_fields["chain_id"] and old_fields["res_name"] in AA_NAMES:
                coords.append(dict2ter(old_fields))
            coords.append("ENDMDL\n")
            coords.append("MODEL     %4i\n" % (fields["model"] + 1))
        coords.append(dict2pdb(fields))
        old_fields = fields
    if fields["res_name"] in AA_NAMES:
        coords.append(dict2ter(fields))
    coords.append("ENDMDL\n")
    coords.append("END   \n")
    return coords