From: Justin Gullingsrud (jgulling_at_mccammon.ucsd.edu)
Date: Mon May 03 2004 - 10:46:33 CDT

Hi,

I'd probably do something like this:

mol load pdb brH.pdb
set sel [atomselect top "name N HN and not resid 1 and not resname PRO"]
foreach { n h } [$sel list] {nres hres} [$sel get resid] {
  puts "$n $h $nres $hres"
}

There are a couple of tricks here. First, I don't want the N-terminal
residue because it's got an NH3 group instead of a normal N-H. I also
don't want proline residues because they don't have an H on the N atom.
Everything else, though, should have one N and one H atom per residue.
Your H atom might be called HN; in the protein I happened to use it's
called HN. The 'foreach' command loops through the list of atom indices
generated by [$sel list] and the resid's generated by [$sel get resid],
pulling off two at a time and storing them in temporary variable names
that I then pass to 'puts'. You can use the resid to check that the N
and H atom are indeed from the same residue.

Another method would be to select just the N atoms, loop over them,
and select hydrogens that are within 1.5 of each N atom:

set natoms [atomselect top "name N"]
foreach n [$natoms list] {
  set h [atomselect top "name H and within 1.5 of index $n"]
  puts "$n $h"
  $h delete
}

This will be slower (creating atom selections takes a relatively long
time), but may be more robust.

Cheers,
Justin

On Mon, May 03, 2004 at 01:56:25PM +0300, Ahmet Bakan wrote:
> Hi Justin and All,
>
> I need the index of the single atom that hydrogen is bonded to.
> Like this
> -NH-CH2-CO-O-
> I have the index of H bonded to N, hundereds of H similar indices.
> I need index of N atom in this example.
>
> I tried this:
> set HATOM [atomselect top "index 547"]
> Result: H
> set connected [atomselect top "same residue as ([$HATOM text])"]
> Result: NH1 H CT1 HB CT2 HA HA CT2 HA HA CC O NH2 H H C O
> set connected [atomselect top "same bond as ([$HATOM text])"]
> Result: nothing happens
>
> Does anyone have idea?
> Thanks,
>
> Ahmet
>
>
> ==========ABC==========
> Ahmet Bakan
> Chemistry, Junior
> Koc University
> abakan_at_ku.edu.tr
> ICQ #86167698
> http://home.ku.edu.tr/~abakan
>
> -----Original Message-----
> From: Justin Gullingsrud [mailto:jgulling_at_mccammon.ucsd.edu]
> Sent: Monday, May 03, 2004 11:36 AM
> To: Ahmet Bakan
> Cc: VMD-L
> Subject: Re: vmd-l: Selection problem on TkCon
>
> Hi,
>
> On Mon, May 03, 2004 at 03:55:43AM +0300, Ahmet Bakan wrote:
> > Hi All,
> >
> >
> >
> > I have a selection of Hydrogen atoms and I want to get the list of atoms
> > that Hydrogens in my selection are attached to. How can this be done on
> > TkCon?
>
> I assume you have a selection that you created from the text console,
> something like this:
>
> set sel [atomselect top "hydrogen and resname ALA"]
>
> Whatever the selection is, you can find all the atoms in the same
> residue as the selection by typing the following:
>
> set connected [atomselect top "same residue as ([$sel text])"]
>
> You can then write out a list of atoms in the selection to a file with:
>
> set fd [open connatoms.ind w]
> foreach ind [$connected list] { puts $fd $ind }
> close $fd
>
> Note that the indicies written to the file will be one smaller than the
> corresponding atom in a pdb file; i.e., they will be 0-based rather than
> 1-based.
>
> Cheers,
> Justin
>
> >
> >
> >
> > Cheers,
> >
> > Ahmet
> >
> >
> >
> > ==========ABC==========
> >
> > Ahmet Bakan
> >
> > Chemistry, Junior
> >
> > Koc University
> >
> > abakan_at_ku.edu.tr
> >
> > ICQ #86167698
> >
> > http://home.ku.edu.tr/~abakan
> >
> >
> >
>
> --
>
> Tenth is 10 spots too low as far as I'm concerned. -- George W. Bush

-- 
Tenth is 10 spots too low as far as I'm concerned.  -- George W. Bush