subroutine char MY_KEY show vari MY_KEY echo " -------------- NEW LINE ------------" wr sele MY_KEY end coor pdb set vari IATOM inte atom sele MY_KEY end show vari IATOM if ( IATOM .le. 0 ) return set vari IATOM2 inte atom sele by bond atom numb IATOM end show vari IATOM2 wr sele atom numb IATOM IATOM2 end coor pdb echo JOIN RESIDUE IATOM IATOM2 join resi IATOM2 IATOM !rena seq Z sele by resi atom numb IATOM end append !rena resi CTR sele by resi atom numb IATOM end wr sele by resi atom numb IATOM end coor pdb key MY_KEY sele MY_KEY .a .n atom numb IATOM end rewind file return