Change entries in a file

Hi

My current file looks like this:

id437  duff    main    57936   79026   1000    +       .       ID=Abf022711;source_id=DUFF380.73.2;
id437  Cuff    stem    57936   79026   1000    +       .       ID=Abf022711.2;source_id=DUFF380.73.2;
id437  duff    main    57936   79026   1000    +       .       ID=Abf022721;source_id=DUFF380.73.2;
id437  Cuff    stem    57936   79026   1000    +       .       ID=Abf022721.2;source_id=DUFF380.73.2;

Is it possible for me to add a parent value for every entry having 3rd tab as stem. So whenever my 3rd tab value is stem, i want to add parent = id value. (no float)

id437  duff    main    57936   79026   1000    +       .       ID=Abf022711;source_id=DUFF380.73.2;
id437  Cuff    stem    57936   79026   1000    +       .       ID=Abf022711.2;Parent=Abf022711;source_id=DUFF380.73.2;
id437  duff    main    57936   79026   1000    +       .       ID=Abf022721;source_id=DUFF380.73.2;
id437  Cuff    stem    57936   79026   1000    +       .       ID=Abf022721.2;Parent=Abf022721;source_id=DUFF380.73.2;

is it possible ?

Making some wild assumptions about where the data for the Parent field is supposed to come from, perhaps something like:

awk '
$3 == "stem" {
	split($9, p, /[=.]/)
	sub(/;/, ";Parent=" p[2] ";")
}
1' file

As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk .

$ perl -pe 's/(?<=\s)(ID=(\w+\d+)\.\d+;)/$1Parent=$2;/' test.file
id437  duff    main    57936   79026   1000    +       .       ID=Abf022711;source_id=DUFF380.73.2;
id437  Cuff    stem    57936   79026   1000    +       .       ID=Abf022711.2;Parent=Abf022711;source_id=DUFF380.73.2;
id437  duff    main    57936   79026   1000    +       .       ID=Abf022721;source_id=DUFF380.73.2;
id437  Cuff    stem    57936   79026   1000    +       .       ID=Abf022721.2;Parent=Abf022721;source_id=DUFF380.73.2;

or

perl -pe 's/(ID=(\w+\d+)\.\d+;)/$1Parent=$2;/ if /stem/' test.file