File: run-unit-test

package info (click to toggle)
python-dnaio 1.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 528 kB
  • sloc: python: 2,726; ansic: 164; sh: 28; makefile: 15
file content (40 lines) | stat: -rw-r--r-- 841 bytes parent folder | download | duplicates (4)
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
#!/bin/bash
set -e

test_pkg=dnaio
# using these data for testing
source_pkg=unicycler-data

if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${test_pkg}-test.XXXXXX)
  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi

if [ -d /usr/share/${source_pkg}/sample_data ] ; then
  cp -a /usr/share/${source_pkg}/sample_data/ ${AUTOPKGTEST_TMP}
else
  echo "Please install package unicycler-data to run this script"
  exit 1
fi

cd ${AUTOPKGTEST_TMP}

cat > simple_test.py << EOL
import os
import dnaio

dir = 'sample_data'

for filename in os.listdir(dir):
    print(filename)
    with dnaio.open(dir + '/' + filename) as inf:
        bp = 0
        for record in inf:
            bp += len(record)
    print(f'The input file contains {bp/1E6:.1f} Mbp')
EOL

# run test
python3 ./simple_test.py

echo "PASS"