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.
This is my cross-tab crystal report for sales per week.
In last column I need the "Change" column at last in which ((21-Jun's value - 14-Jun's value)/14-Jun's value)*100 will be shown.
But I am not be able to achieve that in crystal report.
**Product Customer 31-May 7-Jun 14-Jun 21-Jun**
J.B. Officeprint 1111 Maxi-Teq 4.00 1.00 1.00 1.00
Microchips 1.00 1.00 0.00 0.00
Parameter 2.00 1.00 0.00 0.00
Total 7.00 3.00 1.00 1.00
J.B. Officeprint 1420 Maxi-Teq 4.00 1.00 1.00 1.00
Microchips 1.00 1.00 0.00 1.00
Parameter 2.00 1.00 0.00 1.00
Total 7.00 3.00 1.00 3.00
Motherboard BTX Maxi-Teq 1.00 0.00 0.00 0.00
Total 1.00 0.00 0.00 0.00
Motherboard MicroATX Maxi-Teq 1.00 0.00 0.00 0.00
Total 1.00 0.00 0.00 0.00
Printer Paper A4 Parameter 0.00 0.00 1.00 0.00
Total 0.00 0.00 1.00 0.00
Printer Paper A4 White Maxi-Teq 0.00 0.00 0.00 12.00
Microchips 0.00 0.00 30.00 0.00
Parameter 0.00 0.00 6.00 0.00
Total 0.00 0.00 36.00 12.00
Grand Total 16.00 6.00 39.00 16.00
you can do it using calculated member.
go to the preview and right click on 21-June column and go to calculated member and insert column
Edit..................................................................
Go to edit calculation formula and write your code.
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 have a folder that contains 200 pdb files.I would like to arrange the atom lines of PDB files in ascending order based on the 6th column. I would like to get in-place editing for each pdb file in the folder. your help would be appreciated.
ATOM 81 N ASN A 248 38.791 -16.708 12.507 1.00 52.04 N
ATOM 82 CA ASN A 248 39.443 -17.018 11.206 1.00 54.49 C
ATOM 422 C SER A 205 70.124 -29.955 8.226 1.00 55.81 C
ATOM 423 O SER A 205 70.901 -29.008 8.438 1.00 46.60 O
ATOM 303 N MET A 231 61.031 -38.086 -3.054 1.00 52.32 N
ATOM 304 CA MET A 231 60.580 -39.074 -4.047 1.00 64.11 C
ATOM 392 C GLU B 65 23.248 10.071 -7.321 1.00 48.26 C
ATOM 393 O GLU B 65 24.465 10.200 -7.158 1.00 46.53 O
ATOM 394 O GLU B 65 24.465 10.200 -7.158 1.00 46.53 O
Desired output
ATOM 392 C GLU B 65 23.248 10.071 -7.321 1.00 48.26 C
ATOM 393 O GLU B 65 24.465 10.200 -7.158 1.00 46.53 O
ATOM 394 O GLU B 65 24.465 10.200 -7.158 1.00 46.53 O
ATOM 422 C SER A 205 70.124 -29.955 8.226 1.00 55.81 C
ATOM 423 O SER A 205 70.901 -29.008 8.438 1.00 46.60 O
ATOM 303 N MET A 231 61.031 -38.086 -3.054 1.00 52.32 N
ATOM 304 CA MET A 231 60.580 -39.074 -4.047 1.00 64.11 C
ATOM 81 N ASN A 248 38.791 -16.708 12.507 1.00 52.04 N
ATOM 82 CA ASN A 248 39.443 -17.018 11.206 1.00 54.49 C
Use sort.
sort -n -k 6 inputfile
-n performs numeric sort, and -k tells to sort via a key.
EDIT: For in-place sorting, use the -o option:
sort -n -k 6 inputfile -o inputfile
I use a hash where its key will be the 6th field plus a counter that increments each line appended at the end. This avoids overwrite duplicated entries and keep stable order. Then use asorti() function to sort by that 6th field and print each line of the original array.
Content of script.awk:
{
++n
data[ $6 _ n ] = $0;
}
END {
asorti( data, mod_data, "#ind_num_asc" )
l = length( data )
for ( i = 1; i <= l; i++ ) {
print data[ mod_data[i] ]
}
}
Run it like:
awk -f script.awk infile
That yields:
ATOM 392 C GLU B 65 23.248 10.071 -7.321 1.00 48.26 C
ATOM 393 O GLU B 65 24.465 10.200 -7.158 1.00 46.53 O
ATOM 394 O GLU B 65 24.465 10.200 -7.158 1.00 46.53 O
ATOM 422 C SER A 205 70.124 -29.955 8.226 1.00 55.81 C
ATOM 423 O SER A 205 70.901 -29.008 8.438 1.00 46.60 O
ATOM 303 N MET A 231 61.031 -38.086 -3.054 1.00 52.32 N
ATOM 304 CA MET A 231 60.580 -39.074 -4.047 1.00 64.11 C
ATOM 81 N ASN A 248 38.791 -16.708 12.507 1.00 52.04 N
ATOM 82 CA ASN A 248 39.443 -17.018 11.206 1.00 54.49 C
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.