-
Notifications
You must be signed in to change notification settings - Fork 1
/
mden2csv
executable file
·60 lines (50 loc) · 961 Bytes
/
mden2csv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -eu
SCRIPT_DIR=$(cd $(dirname $0); pwd)
source "${SCRIPT_DIR}"/abstract/files2files
function help(){
abstract_help "mden2csv" "<mden>" "<csv>" "Amber energy file" "csv file" ""
}
function parse_option(){
while [ "${#args[@]}" -gt 1 ]
do
case "${args[1]}" in
-h | -help | --help)
help
exit
# shift_args 1
;;
-*)
error "unknown option: '${args[1]}'"
;;
*)
break
;;
esac
done
}
function get_default_conversion_patt(){
echo '{s/$/.csv/}'
}
function process(){
# $1: inpFile
#
local mdenFile="$1"
local mdenData=`cat "$mdenFile"`
numLinePerFrame=`echo "$mdenData" |
sed -r 's/ .+//' |
sort |
uniq |
wc -l`
sedN=`seq 2 "$numLinePerFrame" |
while read line ;
do
echo -n "N;"
done`
# convert and print
echo "$mdenData" |
sed -r 's/^[^ ]+ +//' | # remove leading Ln
sed -r "{${sedN}s/\n/ /g}" | # convert to newline every frame
sed -r 's/ +/,/g'
}
main "$@"