diff --git a/pdb_b.py b/pdb_b.py index 37c0647a..74309acf 100755 --- a/pdb_b.py +++ b/pdb_b.py @@ -76,11 +76,10 @@ def _alter_bfactor(fhandle, bfactor): #bfactor = str(round(bfactor, 2)).rjust(6) bfactor = "{0:>6.2f}".format(bfactor) for line in fhandle: - line = line.strip() if coord_re.match(line): - yield line[:60] + bfactor + line[66:] + '\n' + yield line[:60] + bfactor + line[66:] else: - yield line + '\n' + yield line if __name__ == '__main__': diff --git a/pdb_chain.py b/pdb_chain.py index 20c6b37d..57b92494 100755 --- a/pdb_chain.py +++ b/pdb_chain.py @@ -78,11 +78,10 @@ def _alter_chain(fhandle, chain_id): chain_id = chain_id for line in fhandle: - line = line.strip() if coord_re.match(line): - yield line[:21] + chain_id[0] + line[22:] + '\n' + yield line[:21] + chain_id[0] + line[22:] else: - yield line + '\n' + yield line if __name__ == '__main__': # Check Input diff --git a/pdb_chainxseg.py b/pdb_chainxseg.py index c11c9fc1..0afc3d04 100755 --- a/pdb_chainxseg.py +++ b/pdb_chainxseg.py @@ -54,16 +54,15 @@ def _swap_chainxseg(fhandle): fhandle = fhandle for line in fhandle: - line = line.strip() if coord_re.match(line): size_of_line = len(line) # Pad short lines if size_of_line < 80: padding = 80 - size_of_line line = line + ' '*padding - yield line[:72] + line[21].ljust(4) + line[76:] + '\n' + yield line[:72] + line[21].ljust(4) + line[76:] else: - yield line + '\n' + yield line if __name__ == '__main__': # Check Input diff --git a/pdb_join.py b/pdb_join.py index 1ffc566e..b81a8200 100755 --- a/pdb_join.py +++ b/pdb_join.py @@ -60,7 +60,7 @@ def _join_pdb(pdb_list): pdb_data.append('MODEL {0:>4d}'.format(i_model)) with open(pdb_f, 'r') as handle: for line in handle: - line = line.strip() + line = line.strip('\n') if coord_re.match(line): pdb_data.append(line) model_auids.add(auid(line)) diff --git a/pdb_occ.py b/pdb_occ.py index f66ed699..0e622b8f 100755 --- a/pdb_occ.py +++ b/pdb_occ.py @@ -75,11 +75,10 @@ def _alter_occupancy(fhandle, occup): coord_re = re.compile('^(ATOM|HETATM)') occup = str(round(occup, 2)).rjust(6) for line in fhandle: - line = line.strip() if coord_re.match(line): - yield line[:54] + occup + line[60:] + '\n' + yield line[:54] + occup + line[60:] else: - yield line + '\n' + yield line if __name__ == '__main__': diff --git a/pdb_reatom.py b/pdb_reatom.py index 73f1fdb6..8737f558 100755 --- a/pdb_reatom.py +++ b/pdb_reatom.py @@ -76,12 +76,11 @@ def _renumber_pdb_atoms(fhandle, satomi): satomi = satomi for line in fhandle: - line = line.strip() if coord_re.match(line): - yield line[:6] + str(satomi).rjust(5) + line[11:] + '\n' + yield line[:6] + str(satomi).rjust(5) + line[11:] satomi += 1 else: - yield line + '\n' + yield line if __name__ == '__main__': diff --git a/pdb_reres.py b/pdb_reres.py index 9bc96757..949835cd 100755 --- a/pdb_reres.py +++ b/pdb_reres.py @@ -75,15 +75,14 @@ def _renumber_pdb_residue(fhandle, sresid): resi = sresid - 1 prev_resi = None for line in fhandle: - line = line.strip() if line.startswith(('ATOM', 'HETATM', 'TER')): if line[22:26] != prev_resi: prev_resi = line[22:26] resi += 1 - yield line[:22] + str(resi).rjust(4) + line[26:] + '\n' + yield line[:22] + str(resi).rjust(4) + line[26:] else: - yield line + '\n' + yield line if __name__ == '__main__': diff --git a/pdb_rplchain.py b/pdb_rplchain.py index 1917c871..ceddbbce 100755 --- a/pdb_rplchain.py +++ b/pdb_rplchain.py @@ -76,11 +76,10 @@ def _alter_chain(fhandle, ori_chain, new_chain): new_chain = ' ' for line in fhandle: - line = line.strip() if coord_re.match(line) and line[21] == ori_chain: - yield line[:21] + new_chain + line[22:] + '\n' + yield line[:21] + new_chain + line[22:] else: - yield line + '\n' + yield line if __name__ == '__main__': # Check Input diff --git a/pdb_seg.py b/pdb_seg.py index 402aa7db..e0b49bcb 100755 --- a/pdb_seg.py +++ b/pdb_seg.py @@ -77,11 +77,10 @@ def _alter_segid(fhandle, seg_id): seg_id = seg_id[0:4].ljust(4) for line in fhandle: - line = line.strip() if coord_re.match(line): - yield line[:72] + seg_id + line[76:] + '\n' + yield line[:72] + seg_id + line[76:] else: - yield line + '\n' + yield line if __name__ == '__main__': # Check Input diff --git a/pdb_selchain.py b/pdb_selchain.py index 4ede082f..11e0a9aa 100755 --- a/pdb_selchain.py +++ b/pdb_selchain.py @@ -77,9 +77,8 @@ def _select_chain(fhandle, chain_id): chain_id = chain_id for line in fhandle: - line = line.strip() if coord_re.match(line) and line[21] == chain_id: - yield line + '\n' + yield line if __name__ == '__main__': # Check Input diff --git a/pdb_selseg.py b/pdb_selseg.py index 4759aec0..c5908c62 100755 --- a/pdb_selseg.py +++ b/pdb_selseg.py @@ -77,9 +77,8 @@ def _select_seg(fhandle, seg_id): seg_id = seg_id for line in fhandle: - line = line.strip() if coord_re.match(line) and line[72:76].strip() == seg_id: - yield line + '\n' + yield line if __name__ == '__main__': # Check Input diff --git a/pdb_splitchain.py b/pdb_splitchain.py index 36473b5a..fd8903de 100755 --- a/pdb_splitchain.py +++ b/pdb_splitchain.py @@ -56,7 +56,6 @@ def _extract_chains(fhandle): for line in fhandle: if coord_re.match(line): - line = line.strip() # ATOM/HETATM line if prev_chain != line[21]: if not line[21] in chain_atoms: @@ -67,7 +66,7 @@ def _extract_chains(fhandle): prev_chain = line[21] chain_ids.append(line[21]) else: - cur_chain.append(line + '\n') + cur_chain.append(line) # Output chains to files for c_id in chain_ids: diff --git a/pdb_splitmodel.py b/pdb_splitmodel.py index 8d791cc5..943ff522 100755 --- a/pdb_splitmodel.py +++ b/pdb_splitmodel.py @@ -54,10 +54,9 @@ def _extract_models(fhandle): output_handle = None for line in fhandle: - line = line.strip() if coord_re.match(line): # ATOM/HETATM line - output_handle.write(line + '\n') + output_handle.write(line) elif line.startswith('MODEL'): model_no = line.split()[-1] output_handle = open(fname_root + '_' + model_no + '.pdb', 'w') diff --git a/pdb_splitseg.py b/pdb_splitseg.py index cd7ba61b..63fe2a90 100755 --- a/pdb_splitseg.py +++ b/pdb_splitseg.py @@ -55,7 +55,6 @@ def _extract_segments(fhandle): prev_segment, segment_atoms = None, [] for line in fhandle: - line = line.strip() if coord_re.match(line): # ATOM/HETATM line if prev_segment != line[72:76]: @@ -66,10 +65,10 @@ def _extract_segments(fhandle): output_handle.write('END\n') output_handle.close() segment_atoms = [] - segment_atoms.append(line + '\n') + segment_atoms.append(line) prev_segment = line[72:76] else: - segment_atoms.append(line + '\n') + segment_atoms.append(line) # Output last chain to file output_handle = open(fname_root + '_' + segment_atoms[-1][72:76].strip() + '.pdb', 'w') diff --git a/pdb_striphet.py b/pdb_striphet.py index 54993735..3b128f40 100755 --- a/pdb_striphet.py +++ b/pdb_striphet.py @@ -52,9 +52,8 @@ def _remove_hetatm(fhandle): coord_re = re.compile('^ATOM') for line in fhandle: - line = line.strip() if coord_re.match(line): - yield line + '\n' + yield line if __name__ == '__main__':