File1 is an hard formatted pdb file containing protein coordinates:
ATOM 1 N MET A 1 -37.809 27.446 34.618 1.00 43.34 N
ATOM 2 CA MET A 1 -37.480 26.307 33.746 1.00 43.34 C
ATOM 3 C MET A 1 -36.495 25.493 34.556 1.00 43.34 C
ATOM 4 CB MET A 1 -36.919 26.801 32.394 1.00 43.34 C
ATOM 5 O MET A 1 -35.346 25.898 34.661 1.00 43.34 O
ATOM 6 CG MET A 1 -36.980 25.729 31.301 1.00 43.34 C
ATOM 7 SD MET A 1 -35.977 26.080 29.826 1.00 43.34 S
ATOM 8 CE MET A 1 -36.833 27.479 29.055 1.00 43.34 C
ATOM 9 N GLU A 2 -36.991 24.516 35.314 1.00 37.48 N
ATOM 10 CA GLU A 2 -36.090 23.617 36.039 1.00 37.48 C
ATOM 11 C GLU A 2 -35.250 22.852 35.010 1.00 37.48 C
ATOM 12 CB GLU A 2 -36.860 22.659 36.957 1.00 37.48 C
ATOM 13 O GLU A 2 -35.776 22.534 33.938 1.00 37.48 O
ATOM 14 CG GLU A 2 -37.467 23.407 38.153 1.00 37.48 C
..............................................................................
..............................................................................
..............................................................................
ATOM 981 N CYS A 123 -15.659 -7.164 13.998 1.00 90.53 N
ATOM 982 CA CYS A 123 -16.801 -7.332 13.106 1.00 90.53 C
ATOM 983 C CYS A 123 -17.894 -8.234 13.699 1.00 90.53 C
ATOM 984 CB CYS A 123 -16.321 -7.886 11.757 1.00 90.53 C
ATOM 985 O CYS A 123 -18.918 -8.425 13.046 1.00 90.53 O
ATOM 986 SG CYS A 123 -15.266 -6.683 10.904 1.00 90.53 S
ATOM 987 N GLY A 124 -17.679 -8.840 14.874 1.00 90.37 N
ATOM 988 CA GLY A 124 -18.641 -9.764 15.474 1.00 90.37 C
ATOM 989 C GLY A 124 -18.851 -11.029 14.637 1.00 90.37 C
ATOM 990 O GLY A 124 -19.970 -11.514 14.513 1.00 90.37 O
ATOM 991 N SER A 125 -17.793 -11.536 13.996 1.00 92.09 N
ATOM 992 CA SER A 125 -17.837 -12.749 13.159 1.00 92.09 C
ATOM 993 C SER A 125 -17.220 -13.976 13.833 1.00 92.09 C
ATOM 994 CB SER A 125 -17.117 -12.481 11.840 1.00 92.09 C
ATOM 995 O SER A 125 -17.538 -15.108 13.459 1.00 92.09 O
ATOM 996 OG SER A 125 -17.831 -11.523 11.084 1.00 92.09 O
....................... plus many more lines .................................
File2 is a list of representative lines obtained from fields 3,4, and 5 of the above
pdb file. To keep all simple, let's consider just to lines:
GLU A 2
GLY A 124
The desired output is:
ATOM 1 N MET A 1 -37.809 27.446 34.618 1.00 43.34 N
ATOM 2 CA MET A 1 -37.480 26.307 33.746 1.00 43.34 C
ATOM 3 C MET A 1 -36.495 25.493 34.556 1.00 43.34 C
ATOM 4 CB MET A 1 -36.919 26.801 32.394 1.00 43.34 C
ATOM 5 O MET A 1 -35.346 25.898 34.661 1.00 43.34 O
ATOM 6 CG MET A 1 -36.980 25.729 31.301 1.00 43.34 C
ATOM 7 SD MET A 1 -35.977 26.080 29.826 1.00 43.34 S
ATOM 8 CE MET A 1 -36.833 27.479 29.055 1.00 43.34 C
ATOM 9 N GLU A 2 -36.991 24.516 35.314 1.00 00.00 N
ATOM 10 CA GLU A 2 -36.090 23.617 36.039 1.00 00.00 C
ATOM 11 C GLU A 2 -35.250 22.852 35.010 1.00 00.00 C
ATOM 12 CB GLU A 2 -36.860 22.659 36.957 1.00 00.00 C
ATOM 13 O GLU A 2 -35.776 22.534 33.938 1.00 00.00 O
ATOM 14 CG GLU A 2 -37.467 23.407 38.153 1.00 00.00 C
..............................................................................
..............................................................................
..............................................................................
ATOM 981 N CYS A 123 -15.659 -7.164 13.998 1.00 90.53 N
ATOM 982 CA CYS A 123 -16.801 -7.332 13.106 1.00 90.53 C
ATOM 983 C CYS A 123 -17.894 -8.234 13.699 1.00 90.53 C
ATOM 984 CB CYS A 123 -16.321 -7.886 11.757 1.00 90.53 C
ATOM 985 O CYS A 123 -18.918 -8.425 13.046 1.00 90.53 O
ATOM 986 SG CYS A 123 -15.266 -6.683 10.904 1.00 90.53 S
ATOM 987 N GLY A 124 -17.679 -8.840 14.874 1.00 00.00 N
ATOM 988 CA GLY A 124 -18.641 -9.764 15.474 1.00 00.00 C
ATOM 989 C GLY A 124 -18.851 -11.029 14.637 1.00 00.00 C
ATOM 990 O GLY A 124 -19.970 -11.514 14.513 1.00 00.00 O
ATOM 991 N SER A 125 -17.793 -11.536 13.996 1.00 92.09 N
ATOM 992 CA SER A 125 -17.837 -12.749 13.159 1.00 92.09 C
ATOM 993 C SER A 125 -17.220 -13.976 13.833 1.00 92.09 C
ATOM 994 CB SER A 125 -17.117 -12.481 11.840 1.00 92.09 C
ATOM 995 O SER A 125 -17.538 -15.108 13.459 1.00 92.09 O
ATOM 996 OG SER A 125 -17.831 -11.523 11.084 1.00 92.09 O
i.e. a modified pdb with 00.00 in the 11th field if a File1's line contain a
File2 occurrence.
I already know how to do that with Bash while-read and awk but because these tools
change the format and require reformatting and/or specify the output format, in this
particular case dealing with hundreds of files they are not practical.
In order to avoid these problems I decided to look for a solution based on sed.
I got a working solution if I explicitly give a single search pattern. i.e. the
following code works:
digits=00.00
sed "/GLU A 2/s/\(.\{61\}\)\(.\{5\}\)/\1$digits/" File1.pdb > out.pdb
but the following does not (the File1 lines are unchanged) and I did not manage
to figure out why:
digits=00.00
while read pattern; do
sed "/$pattern/s/\(.\{61\}\)\(.\{5\}\)/\1$digits/" File1.pdb > out.pdb ;
done < File2.txt
Sorry for the lengthy message. Thanks in advance for any help.
#anubhava:
using my real data this is what happen at the first substitution site:
ATOM 293 CE1 HIS A 38 -18.278 19.735 13.486 1.00 67.94 C
ATOM 294 NE2 HIS A 38 -18.518 18.594 14.144 1.00 67.94 N
ATOM 295 N GLY A 39 -13.836 00.00 9.206 1.00 71.50 N
ATOM 296 CA GLY A 39 -12.628 00.00 8.447 1.00 71.50 C
ATOM 297 C GLY A 39 -11.358 00.00 9.286 1.00 71.50 C
ATOM 298 O GLY A 39 -11.411 18.636 10.344 1.00 00.00 O
ATOM 299 N PRO A 40 -10.180 17.577 8.797 1.00 71.93 N
ATOM 300 CA PRO A 40 -8.908 17.719 9.520 1.00 71.93 C
ATOM 301 C PRO A 40 -8.580 19.169 9.912 1.00 71.93 C
In this case the site is /GLY A 39/. As you can see there is a shift in some lines and unwanted substitutions in the 8th field.
Strange enough such problems occur only for the first replacement i.e. the remaning output is just perfect. Thanks.
Using sed in a while loop which reads file 2 line by line, you can target only lines matches those found in file2 and carry out the sub on those lines where;
s/\(.*\)[0-9]\{2\}\.[0-9]\{2\}\([[:space:]]\+.*$\)/ - Group everything up to the last digits that matches the pattern and retain to be returned with back reference \1. Exclude the number matched in the pattern and once again group everything else after from the space to the end of the line and return with back-reference \2
$ cat file1
ATOM 1 N MET A 1 -37.809 27.446 34.618 1.00 43.34 N
ATOM 2 CA MET A 1 -37.480 26.307 33.746 1.00 43.34 C
ATOM 3 C MET A 1 -36.495 25.493 34.556 1.00 43.34 C
ATOM 4 CB MET A 1 -36.919 26.801 32.394 1.00 43.34 C
ATOM 5 O MET A 1 -35.346 25.898 34.661 1.00 43.34 O
ATOM 6 CG MET A 1 -36.980 25.729 31.301 1.00 43.34 C
ATOM 7 SD MET A 1 -35.977 26.080 29.826 1.00 43.34 S
ATOM 8 CE MET A 1 -36.833 27.479 29.055 1.00 43.34 C
ATOM 9 N GLU A 2 -36.991 24.516 35.314 1.00 37.48 N
ATOM 10 CA GLU A 2 -36.090 23.617 36.039 1.00 37.48 C
ATOM 11 C GLU A 2 -35.250 22.852 35.010 1.00 37.48 C
ATOM 12 CB GLU A 2 -36.860 22.659 36.957 1.00 37.48 C
ATOM 13 O GLU A 2 -35.776 22.534 33.938 1.00 37.48 O
ATOM 14 CG GLU A 2 -37.467 23.407 38.153 1.00 37.48 C
ATOM 981 N CYS A 123 -15.659 -7.164 13.998 1.00 90.53 N
ATOM 982 CA CYS A 123 -16.801 -7.332 13.106 1.00 90.53 C
ATOM 983 C CYS A 123 -17.894 -8.234 13.699 1.00 90.53 C
ATOM 984 CB CYS A 123 -16.321 -7.886 11.757 1.00 90.53 C
ATOM 985 O CYS A 123 -18.918 -8.425 13.046 1.00 90.53 O
ATOM 986 SG CYS A 123 -15.266 -6.683 10.904 1.00 90.53 S
ATOM 987 N GLY A 124 -17.679 -8.840 14.874 1.00 90.37 N
ATOM 988 CA GLY A 124 -18.641 -9.764 15.474 1.00 90.37 C
ATOM 989 C GLY A 124 -18.851 -11.029 14.637 1.00 90.37 C
ATOM 990 O GLY A 124 -19.970 -11.514 14.513 1.00 90.37 O
ATOM 991 N SER A 125 -17.793 -11.536 13.996 1.00 92.09 N
ATOM 992 CA SER A 125 -17.837 -12.749 13.159 1.00 92.09 C
ATOM 993 C SER A 125 -17.220 -13.976 13.833 1.00 92.09 C
ATOM 994 CB SER A 125 -17.117 -12.481 11.840 1.00 92.09 C
ATOM 995 O SER A 125 -17.538 -15.108 13.459 1.00 92.09 O
ATOM 996 OG SER A 125 -17.831 -11.523 11.084 1.00 92.09 O
$ while read -r line; do sed -i.bak "/$line/s/\(.*\)[0-9]\{2\}\.[0-9]\{2\}\([[:space:]]\+.*$\)/\100.00\2/" file1; done < file2
$ cat file1
ATOM 1 N MET A 1 -37.809 27.446 34.618 1.00 43.34 N
ATOM 2 CA MET A 1 -37.480 26.307 33.746 1.00 43.34 C
ATOM 3 C MET A 1 -36.495 25.493 34.556 1.00 43.34 C
ATOM 4 CB MET A 1 -36.919 26.801 32.394 1.00 43.34 C
ATOM 5 O MET A 1 -35.346 25.898 34.661 1.00 43.34 O
ATOM 6 CG MET A 1 -36.980 25.729 31.301 1.00 43.34 C
ATOM 7 SD MET A 1 -35.977 26.080 29.826 1.00 43.34 S
ATOM 8 CE MET A 1 -36.833 27.479 29.055 1.00 43.34 C
ATOM 9 N GLU A 2 -36.991 24.516 35.314 1.00 00.00 N
ATOM 10 CA GLU A 2 -36.090 23.617 36.039 1.00 00.00 C
ATOM 11 C GLU A 2 -35.250 22.852 35.010 1.00 00.00 C
ATOM 12 CB GLU A 2 -36.860 22.659 36.957 1.00 00.00 C
ATOM 13 O GLU A 2 -35.776 22.534 33.938 1.00 00.00 O
ATOM 14 CG GLU A 2 -37.467 23.407 38.153 1.00 00.00 C
ATOM 981 N CYS A 123 -15.659 -7.164 13.998 1.00 90.53 N
ATOM 982 CA CYS A 123 -16.801 -7.332 13.106 1.00 90.53 C
ATOM 983 C CYS A 123 -17.894 -8.234 13.699 1.00 90.53 C
ATOM 984 CB CYS A 123 -16.321 -7.886 11.757 1.00 90.53 C
ATOM 985 O CYS A 123 -18.918 -8.425 13.046 1.00 90.53 O
ATOM 986 SG CYS A 123 -15.266 -6.683 10.904 1.00 90.53 S
ATOM 987 N GLY A 124 -17.679 -8.840 14.874 1.00 00.00 N
ATOM 988 CA GLY A 124 -18.641 -9.764 15.474 1.00 00.00 C
ATOM 989 C GLY A 124 -18.851 -11.029 14.637 1.00 00.00 C
ATOM 990 O GLY A 124 -19.970 -11.514 14.513 1.00 00.00 O
ATOM 991 N SER A 125 -17.793 -11.536 13.996 1.00 92.09 N
ATOM 992 CA SER A 125 -17.837 -12.749 13.159 1.00 92.09 C
ATOM 993 C SER A 125 -17.220 -13.976 13.833 1.00 92.09 C
ATOM 994 CB SER A 125 -17.117 -12.481 11.840 1.00 92.09 C
ATOM 995 O SER A 125 -17.538 -15.108 13.459 1.00 92.09 O
ATOM 996 OG SER A 125 -17.831 -11.523 11.084 1.00 92.09 O
awk suites this role better:
awk 'FNR==NR {a[$1,$2,$3]; next} ($4,$5,$6) in a {$11="00.00"} 1' file2 file1 | column -t
ATOM 1 N MET A 1 -37.809 27.446 34.618 1.00 43.34 N
ATOM 2 CA MET A 1 -37.480 26.307 33.746 1.00 43.34 C
ATOM 3 C MET A 1 -36.495 25.493 34.556 1.00 43.34 C
ATOM 4 CB MET A 1 -36.919 26.801 32.394 1.00 43.34 C
ATOM 5 O MET A 1 -35.346 25.898 34.661 1.00 43.34 O
ATOM 6 CG MET A 1 -36.980 25.729 31.301 1.00 43.34 C
ATOM 7 SD MET A 1 -35.977 26.080 29.826 1.00 43.34 S
ATOM 8 CE MET A 1 -36.833 27.479 29.055 1.00 43.34 C
ATOM 9 N GLU A 2 -36.991 24.516 35.314 1.00 00.00 N
ATOM 10 CA GLU A 2 -36.090 23.617 36.039 1.00 00.00 C
ATOM 11 C GLU A 2 -35.250 22.852 35.010 1.00 00.00 C
ATOM 12 CB GLU A 2 -36.860 22.659 36.957 1.00 00.00 C
ATOM 13 O GLU A 2 -35.776 22.534 33.938 1.00 00.00 O
ATOM 14 CG GLU A 2 -37.467 23.407 38.153 1.00 00.00 C
ATOM 981 N CYS A 123 -15.659 -7.164 13.998 1.00 90.53 N
ATOM 982 CA CYS A 123 -16.801 -7.332 13.106 1.00 90.53 C
ATOM 983 C CYS A 123 -17.894 -8.234 13.699 1.00 90.53 C
ATOM 984 CB CYS A 123 -16.321 -7.886 11.757 1.00 90.53 C
ATOM 985 O CYS A 123 -18.918 -8.425 13.046 1.00 90.53 O
ATOM 986 SG CYS A 123 -15.266 -6.683 10.904 1.00 90.53 S
ATOM 987 N GLY A 124 -17.679 -8.840 14.874 1.00 00.00 N
ATOM 988 CA GLY A 124 -18.641 -9.764 15.474 1.00 00.00 C
ATOM 989 C GLY A 124 -18.851 -11.029 14.637 1.00 00.00 C
ATOM 990 O GLY A 124 -19.970 -11.514 14.513 1.00 00.00 O
ATOM 991 N SER A 125 -17.793 -11.536 13.996 1.00 92.09 N
ATOM 992 CA SER A 125 -17.837 -12.749 13.159 1.00 92.09 C
ATOM 993 C SER A 125 -17.220 -13.976 13.833 1.00 92.09 C
ATOM 994 CB SER A 125 -17.117 -12.481 11.840 1.00 92.09 C
ATOM 995 O SER A 125 -17.538 -15.108 13.459 1.00 92.09 O
ATOM 996 OG SER A 125 -17.831 -11.523 11.084 1.00 92.09 O
Used column -t for tabular output display only.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I currently have a text file that starts like this,
ATOM 277 N DOPC 3 2.637 5.546 17.667 1.00 0.00 MEMB
ATOM 278 C12 DOPC 3 2.869 5.398 19.176 1.00 0.00 MEMB
ATOM 279 H12A DOPC 3 3.729 6.005 19.418 1.00 0.00 MEMB
ATOM 280 H12B DOPC 3 3.176 4.394 19.427 1.00 0.00 MEMB
ATOM 281 C13 DOPC 3 1.352 4.873 17.275 1.00 0.00 MEMB
ATOM 282 H13A DOPC 3 1.380 5.091 16.217 1.00 0.00 MEMB
ATOM 283 H13B DOPC 3 1.415 3.810 17.452 1.00 0.00 MEMB
ATOM 284 H13C DOPC 3 0.491 5.261 17.799 1.00 0.00 MEMB
ATOM 285 C14 DOPC 3 3.791 4.845 16.976 1.00 0.00 MEMB
ATOM 286 H14A DOPC 3 4.692 4.989 17.554 1.00 0.00 MEMB
ATOM 287 H14B DOPC 3 3.563 3.790 17.025 1.00 0.00 MEMB
ATOM 288 H14C DOPC 3 3.875 5.097 15.930 1.00 0.00 MEMB
ATOM 289 C15 DOPC 3 2.627 6.991 17.324 1.00 0.00 MEMB
ATOM 290 H15A DOPC 3 1.812 7.530 17.785 1.00 0.00 MEMB
.
.
I'm wondering if there is any way using sed or awk to reorder the lines so that the ordering goes from [1,2,3...14...] to [1,2,5,9,13,3,4,6,7,8,10,11,12,14...] just by simply using their unique line number?
Here is the desired output,
ATOM 277 N DOPC 3 2.637 5.546 17.667 1.00 0.00 MEMB
ATOM 278 C12 DOPC 3 2.869 5.398 19.176 1.00 0.00 MEMB
ATOM 281 C13 DOPC 3 1.352 4.873 17.275 1.00 0.00 MEMB
ATOM 285 C14 DOPC 3 3.791 4.845 16.976 1.00 0.00 MEMB
ATOM 289 C15 DOPC 3 2.627 6.991 17.324 1.00 0.00 MEMB
ATOM 279 H12A DOPC 3 3.729 6.005 19.418 1.00 0.00 MEMB
ATOM 280 H12B DOPC 3 3.176 4.394 19.427 1.00 0.00 MEMB
ATOM 284 H13C DOPC 3 0.491 5.261 17.799 1.00 0.00 MEMB
ATOM 286 H14A DOPC 3 4.692 4.989 17.554 1.00 0.00 MEMB
ATOM 287 H14B DOPC 3 3.563 3.790 17.025 1.00 0.00 MEMB
ATOM 288 H14C DOPC 3 3.875 5.097 15.930 1.00 0.00 MEMB
ATOM 290 H15A DOPC 3 1.812 7.530 17.785 1.00 0.00 MEMB
.
.
Thanks!
In awk:
$ awk -v order="1,2,5,9,13,3,4,6,7,8,10,11,12,13,14" '{
a[NR]=$0 # hash records to a with NR as index
}
END {
n=split(order,o,/,/) # split the given order to a mapping
for(i=1;i<=n;i++) { # iterate the map indexes
print a[o[i]] # output
# delete a[o[i]] # uncomment these
}
# for(i=1;i<=NR;i++) # to print any leftovers
# if(i in a) # that were not in the order list
# print a[i]
}' file
Use this Perl one-liner:
perl -ne 'push #a, $_; END { print $a[$_-1] for ( 1,2,5,9,13,3,4,6,7,8,10,11,12,13,14, 15..($#a+1) ); }' in_file > out_file
The Perl one-liner uses these command line flags:
-e : Tells Perl to look for code in-line, instead of in a file.
-n : Loop over the input one line at a time, assigning it to $_ by default.
push #a, $_; : Add to the array #a (which is empty initially) the current line as the next element.
$#a : The index of the last element of the array #a.
END { ... } : After all input lines have been read, execute the code inside the block. Here, print the lines in the specified order.
Recently I needed to speed up a legacy project(use zend framework 1.10.2),that project use zend_cache,I am new in zend framework.
the default.ini configure:
data.cache.interim.frontend.name = "Core"
data.cache.interim.frontend.options.lifetime = 311040000 ; 10 years
data.cache.interim.backend.name = "File"
data.cache.interim.backend.options.cache_dir = "/cache/dp-interim/"
data.cache.interim.backend.options.hashed_directory_level = 3
There have 506790 cache files in /cache/dp-interim (run command: ls -lR | grep "^-" | wc -l on /cache/dp-interim get the result).
run "iotop",get the result: TOTAL DISK READ : 1034.22K/s
run "iostat",the result:
avg-cpu: %user %nice %system %iowait %steal %idle
1.80 0.00 0.77 51.80 0.00 45.62
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 48.00 0.00 245.00 0.00 2344.00 0.00 9.57 1.51 6.16 3.95 96.80
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
2.05 0.00 1.03 45.90 0.00 51.03
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 43.00 0.00 214.00 0.00 2056.00 0.00 9.61 1.10 5.20 4.47 95.60
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
2.06 0.00 0.26 46.91 0.00 50.77
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 62.00 0.00 196.00 0.00 2064.00 0.00 10.53 1.64 8.33 5.06 99.20
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
qavg-cpu: %user %nice %system %iowait %steal %idle
2.33 0.00 2.59 45.34 0.00 49.74
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 33.00 0.00 331.00 0.00 2912.00 0.00 8.80 0.99 3.01 2.68 88.80
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
It is the larger cache file cause the IO height?
Thanks for you help!
I'm very new to matlab and am more of an ArcGIS user but I'd like to know how I can read asc files into Matlab and read coordinates.
The asc file is as follows (sorry it is huge!)
ncols 32
nrows 32
xllcenter -58.75
yllcenter -38.75
cellsize 2.5
NODATA_value -999
0.00 0.62 0.60 0.38 1.22
0.52 1.09 0.76 0.00 0.94
0.37 0.52 0.71 0.71 1.38
0.13 0.00 0.00 0.00 1.46
0.00 0.00 0.97 0.00 0.41
0.00 0.00 0.41 0.83 0.00
0.00 0.19 0.32 0.00 0.00
0.00 0.86 0.00 0.52 1.34
0.00 1.29 0.00 0.00 1.40
0.83 0.00 0.00 0.00 0.00
0.00 0.00 1.09 0.20 0.00
0.43 0.00 0.96 0.78 0.26
0.00 0.70 0.00 0.92 0.29
0.00 1.19 0.00 1.24 0.73
0.00 1.41 0.00 0.97 1.01
0.66 0.00 0.01 0.67 0.67
0.32 0.69 1.41 0.00 0.08
0.92 0.00 0.00 0.40 0.00
0.00 0.00 0.00 1.27 1.24
0.22 0.00 0.00 0.76 0.86
0.00 0.05 0.67 0.29 0.00
0.00 0.04 0.00 0.00 1.18
0.46 0.20 0.00 0.81 0.00
0.00 0.00 1.35 0.40 1.03
0.94 0.90 0.80 0.26 0.73
0.69 0.36 0.70 0.00 0.00
0.42 1.23 0.00 1.24 0.52
0.00 0.54 1.39 1.44 0.00
1.18 0.10 0.00 0.00 0.78
1.33 0.58 0.00 0.00 0.00
0.00 0.92 0.00 0.00 0.00
1.03 0.00 0.00 0.00 0.00
0.66 0.92 0.73 0.00 0.99
0.00 0.00 1.39 0.49 0.97
0.00 1.29 0.00 1.41 1.06
0.00 1.00 0.00 0.00 0.00
0.00 0.32 0.69 1.26 0.00
0.00 0.71 0.00 1.08 1.16
0.00 0.00 0.48 0.00 1.17
0.24 0.00 0.00 0.41 0.00
1.24 1.30 0.00 0.00 0.00
0.00 1.23 0.00 0.15 0.00
0.00 0.19 0.00 0.00 1.17
1.41 0.00 0.15 0.48 0.20
1.29 0.00 0.22 0.55 0.00
0.00 0.81 0.00 0.00 0.00
0.00 1.18 1.18 0.00 0.75
1.05 1.18 1.35 0.00 0.82
0.00 0.00 0.25 0.52 0.00
0.00 1.27 1.46 0.00 1.24
0.00 1.03 1.21 0.81 0.00
0.57 0.00 0.00 0.00 0.00
1.06 0.00 1.29 0.70 0.00
0.00 1.01 0.00 0.00 0.00
0.21 0.95 0.00 0.00 0.00
1.23 1.08 0.00 0.00 0.00
0.11 0.00 0.00 0.00 0.00
0.00 0.00 0.76 0.00 0.68
0.10 0.64 0.00 0.72 0.00
1.34 0.53 0.00 0.18 0.00
0.00 0.25 0.22 0.00 0.00
0.00 0.67 0.37 0.00 0.08
0.02 0.00 0.00 0.94 0.52
0.83 0.64 0.00 0.93 1.40
1.03 0.50 0.00 1.20 0.00
0.68 0.00 0.00 1.15 1.20
0.00 0.00 0.00 0.93 0.00
1.25 0.94 1.37 0.00 0.00
0.00 0.77 0.00 1.15 0.66
0.00 1.45 0.00 1.48 0.00
0.36 0.00 0.34 0.00 0.00
1.22 0.74 0.00 0.00 1.17
0.00 0.59 0.00 0.00 1.18
1.32 1.31 1.21 0.45 1.06
0.00 0.18 0.21 0.79 0.47
0.00 0.47 0.00 0.53 0.76
0.00 0.92 0.00 0.00 1.23
1.45 0.00 0.00 0.00 0.00
1.02 0.00 0.00 0.46 0.00
0.00 0.00 0.00 0.38 1.25
0.00 1.25 0.00 0.42 0.17
0.00 0.97 0.20 0.00 0.00
0.31 0.20 0.00 0.00 0.00
0.00 0.70 0.66 0.00 1.15
0.00 0.00 0.91 1.10 0.00
0.12 0.73 0.00 0.19 0.00
1.01 0.00 0.44 0.00 0.21
0.00 0.00 0.00 0.00 0.91
0.01 0.00 1.28 0.00 0.00
0.00 0.16 0.50 0.00 0.00
1.50 0.10 0.00 0.00 0.00
0.07 0.07 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.88
0.00 0.43 0.00 0.00 0.00
0.00 1.23 0.00 1.41 0.33
0.00 0.74 0.00 0.00 0.00
0.74 0.76 0.15 1.07 0.00
0.00 0.00 0.00 1.34 1.20
0.00 0.00 0.00 0.00 0.43
0.22 0.00 1.02 0.99 0.80
0.91 0.75 0.02 0.00 0.18
0.25 0.00 0.52 0.60 0.00
1.11 0.43 0.00 0.00 0.83
1.02 0.76 0.20 0.00 1.24
0.00 0.00 0.00 1.21 0.00
0.00 0.00 0.00 0.00 0.25
0.00 0.00 0.00 0.00 0.87
0.00 0.00 0.00 1.47 1.22
0.86 0.00 0.96 0.60 0.70
0.38 0.09 0.85 1.18 0.49
0.03 0.00 0.00 1.23 0.00
0.00 0.00 0.00 1.06 0.00
1.01 1.39 1.01 0.00 0.00
0.00 0.00 0.00 0.00 1.31
0.00 0.75 0.00 1.22 0.81
1.07 0.00 0.00 0.00 1.12
1.05 0.70 0.13 0.64 1.30
0.00 0.00 0.53 0.47 0.03
0.00 0.00 0.10 1.38 1.32
0.00 1.25 0.00 0.91 0.67
0.00 0.00 0.00 0.00 0.00
1.00 1.14 0.00 0.00 0.52
0.00 0.02 0.15 0.01 0.90
0.00 0.00 0.70 0.00 0.00
0.00 0.00 0.00 0.00 0.00
0.12 0.72 0.00 0.00 0.04
0.01 0.00 0.00 1.11 1.43
0.91 0.34 0.97 0.00 0.07
0.00 0.00 0.00 0.00 0.93
0.00 0.93 0.00 0.00 0.00
0.93 0.00 0.88 0.29 0.00
0.00 1.50 0.00 0.05 0.00
0.00 0.00 0.00 0.76 1.26
0.00 0.43 0.55 0.40 0.28
0.00 0.07 0.51 0.51 0.00
0.76 0.00 0.00 0.41 0.10
1.16 0.07 0.00 0.00 0.65
0.00 0.21 0.00 0.00 1.41
0.00 1.31 0.19 1.44 0.00
0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.94 0.00
1.12 0.68 0.00 0.00 0.81
0.00 0.00 0.00 0.96 0.00
0.38 0.00 0.00 0.46 0.00
1.15 0.36 0.70 1.04 0.89
1.47 1.20 0.00 0.35 0.00
0.49 0.00 0.00 1.48 0.00
0.00 0.45 1.42 0.00 1.12
0.00 0.00 1.20 1.27 0.00
0.00 0.68 0.30 0.00 0.00
1.20 0.00 0.89 0.00 0.00
0.00 0.00 0.00 0.00 0.00
0.00 1.10 0.48 1.48 0.00
1.23 0.00 1.05 0.56 0.86
0.00 0.00 0.15 0.00 0.03
0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.03 0.90 0.00
0.00 0.00 1.10 0.11 0.68
0.07 0.00 0.78 1.28 1.06
0.39 0.46 0.26 0.00 0.00
0.00 0.85 0.00 0.81 0.00
0.04 0.86 0.00 0.00 0.00
0.00 0.00 0.00 1.45 0.00
0.00 0.00 0.15 0.00 0.00
0.50 0.60 0.00 1.33 0.00
1.15 0.00 1.44 0.82 0.00
0.00 0.01 0.65 0.30 0.00
0.03 0.76 1.12 0.00 0.00
0.59 0.00 0.14 1.16 0.75
0.00 0.00 0.00 0.00 0.00
0.00 1.24 0.41 0.54 1.36
0.00 0.06 0.00 0.00 0.00
0.00 0.76 0.18 1.00 0.00
0.00 0.00 0.00 1.08 0.00
0.00 0.34 0.00 0.82 0.00
0.54 0.00 0.55 0.00 0.97
1.29 0.22 0.00 0.07 0.00
1.31 1.43 0.00 0.35 1.37
0.81 0.00 0.25 0.00 0.90
0.57 0.58 0.00 0.47 0.00
0.51 0.00 0.00 0.50 0.00
0.00 0.00 0.00 1.21 0.23
0.00 0.00 0.00 0.11 0.00
1.08 1.04 0.72 0.00 0.00
0.00 0.00 0.15 0.00 0.80
0.00 0.60 0.00 0.00 1.02
0.00 1.27 0.38 0.69 0.00
1.23 0.00 0.68 0.00 0.31
0.00 0.95 0.00 0.09 0.00
0.00 0.28 0.00 0.00 0.45
0.67 0.92 0.53 1.28 0.13
0.00 0.00 1.02 0.51 0.00
0.00 0.18 0.00 0.00 0.00
0.00 0.00 0.31 0.00 0.98
0.00 0.00 0.00 1.15 0.89
0.00 0.00 0.00 0.42 0.00
1.31 1.27 0.00 0.00 0.00
0.00 0.00 1.23 1.13 0.00
1.05 0.00 0.38 0.00 0.00
0.02 0.00 0.14 0.33 0.12
0.00 0.00 0.00 0.00 0.00
0.00 0.00 1.35 0.18 0.03
0.00 0.00 0.44 0.00 0.00
0.00 1.31 0.19 0.78 0.00
1.17 0.03 1.00 1.02 0.72
nrows and ncols are the number of rows/columns
xllcenter and yllcenter are the coordinates of the centre of the square in the bottom left hand corner of the grid
the cell size is the length of one side of a grid square.
I can read the matrix in and choose to print out values according to their position in the matrix but how would I assign coordinates to such a matrix?
Can I then ask matlab to output the appropriate matrix values when I put in coordinates?
Thanks everyone who can offer me advice!
Since you are a beginner with Matlab, I suggest you investigate the menu option File | Import Data and then study the documentation of the uiimport function.
I have lines as this
ATOM 21001 O WAT 345 7.556 35.954 37.464 0.00 0.00
ATOM 21002 H1 WAT 345 7.076 35.701 36.675 0.00 0.00
ATOM 21003 H2 WAT 345 7.155 35.440 38.164 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21004 O WAT 346 1.183 42.629 26.928 0.00 0.00
ATOM 21005 H1 WAT 346 1.412 43.325 26.313 0.00 0.00
ATOM 21006 H2 WAT 346 1.454 41.823 26.490 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21007 O WAT 347 7.166 53.716 22.860 0.00 0.00
ATOM 21008 H1 WAT 347 7.950 54.234 22.675 0.00 0.00
ATOM 21009 H2 WAT 347 6.855 54.045 23.704 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21010 O WAT 348 9.342 45.695 11.193 0.00 0.00
ATOM 21011 H1 WAT 348 8.488 45.846 10.788 0.00 0.00
ATOM 21012 H2 WAT 348 9.973 45.870 10.494 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21013 O WAT 349 18.303 47.277 18.814 0.00 0.00
ATOM 21014 H1 WAT 349 17.411 47.357 18.476 0.00 0.00
ATOM 21015 H2 WAT 349 18.862 47.407 18.047 0.00 0.00
I want to delete all the characters in line contains TER except the TER word.
I have searched Internet for sed command which can do this but i can not find one which matching specific word.
Could anyone help?
You need to use the following:
sed 's/^TER.*$/TER/'