I have a rather long csh script that works, but it's terribly ungraceful and takes a while from various loops. I only know enough code to get myself into trouble, so I'm looking for some guidance.
I have a large file that is separated at regular intervals by the same line, like this:
@<TRIPOS>molecule
name_000
blah
yadda
stuff
@<TRIPOS>molecule
name_001
blah2
yadda2
stuff2
@<TRIPOS>molecule
name_002
blah3
...
and so on for up to name_200
I need to split this file into individual files, named name_000.mol2, name_001.mol2, name_002.mol2 etc, each of which contain:
@<TRIPOS>molecule
name_000 (or name_whatever)
blah
yadda
stuff
Currently I grep -n 'TRIPOS>molecule' the big file into another file, then use the line numbers to cycle through and pull out lines x through y, naming each file based on what's in line x+1 (name_000), with .mol2 on the end. This takes an incredibly long time, and is rather clunky. I don't know if it's the file cycling or all the variables I pass back and forth that eats up the time, but if anyone knows of an easier way to split the big file up, I would greatly appreciative!
Any ideas?
Thanks!
I have a large file that is separated at regular intervals by the same line, like this:
@<TRIPOS>molecule
name_000
blah
yadda
stuff
@<TRIPOS>molecule
name_001
blah2
yadda2
stuff2
@<TRIPOS>molecule
name_002
blah3
...
and so on for up to name_200
I need to split this file into individual files, named name_000.mol2, name_001.mol2, name_002.mol2 etc, each of which contain:
@<TRIPOS>molecule
name_000 (or name_whatever)
blah
yadda
stuff
Currently I grep -n 'TRIPOS>molecule' the big file into another file, then use the line numbers to cycle through and pull out lines x through y, naming each file based on what's in line x+1 (name_000), with .mol2 on the end. This takes an incredibly long time, and is rather clunky. I don't know if it's the file cycling or all the variables I pass back and forth that eats up the time, but if anyone knows of an easier way to split the big file up, I would greatly appreciative!
Any ideas?
Thanks!