This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Script for extracting atomic position of nucleotide base

Hi everyone.

I have a tab-delimited tabular file (indicated below) including information about the atomic positions of nucleotide bases. My question is that how can I get first 10 lines of every 20000 lines in a datasheet has 10^7 lines. Basically, is there any script for such a purpose?

BaseAtomNumber        atomic distances    NumberofNeighbour    IndexofAtom
1                     1.94895             655                  153   
1                     2.34545             566                  543
..
..

Many thanks in advance for your help!

next-gen assembly genome

1 answer

Assuming your files have a single line header that needs stripping first, as shown, then something like:

tail -n+2 <yourfile> \
| split -l 20000 - <yourprefix> \
&& find <yourprefix>* -exec bash -c 'head -n10 {}' \; \
> <youroutfile> \
&& rm <yourprefix>*

Strips the header, splits the file into separate files of size 20k lines, takes the top 10 rows of each to an output file and then deletes the intermediate files afterwards (make sure nothing else shares <yourprefix>*, or it'll be deleted too).

We tried this and it works well, thanks for your help.

Log in to answer this question.