[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[WOT] sh script to relace chars in #1 w/ chars in #2?



Hi, 

I have written about 5 successful low-level scripts to do various things,
and want to learn more about the ways, but I'm in a time crunch (classes
are starting next week) and I can't begin to grok what's needed for this.
I was hoping some kind, (bored?) soul could throw clues this way.. ??  :)

I have done some programming _long ago_ in Basic and APL, so I have a clear
picture of how things like this can be put together, but I don't know the
tools at all.  I envision setting counters (using grep/wc), a do loop, and
sed or perl in there somewhere, but..?  

I have a program which changes molecular file formats from one type to
another.  I have a collection of several hundred files in one format which
need to be changed to another.  The converter improperly identifies some of
the atom labels in this particular format.  Those it screws up on get
labeled "Du" and need to be relabeled.  I have notified the creators about
this, but no response...

Input files: <name>.m3d		output files: <name>.pdb

In each file, individual atoms take up a line each.

The list of atoms in the input file always start on the 3rd line, and the
labels cover columns 7 and 8 (one or two letters/symbol, space if no 2nd
letter).  I have yet to see an improperly constructed file.

The list begins on line 3 in the output file, with symbols in col. 14,15.
This format is definitely consistent, coming out of the converter app.

Other lines follow the list in both files. So...
  input file:		 output file:
..........		........
..........		........
......O ....		........
......H ....		ATOM.........Du.... <-- needs to change to "O "
......H ....		ATOM.........H ....
........		ATOM.........H ....
			.........

Since each file has different numbers of atoms, the number of atoms can be
determined by the number of lines in the output file which begin with
"ATOM".  The two lists parallel one other.

My thoughts were to simply replace All labels in the output file with the
corresponding ones in the input file, though elegance points to doing a
comparison and switching if necessary (might be good as a check too,
perhaps?).

If anyone can throw thoughts my way, I'd REALLY appreciate it (call me
anytime for cab fare... :)

Thanks,

Kenward
-- 
It is not so very important for a person to learn facts.  For that he
doesn't really need a college education, for he can learn them from
books.  The value of an education in a liberal arts college is not the
learning of many facts but the training of the mind to thinking--something
that cannot be learned from books.     Albert Einstein



Reply to: