Skip to content

Commit

Permalink
Merge pull request #19 from gtamazian/binary-package
Browse files Browse the repository at this point in the history
Routines and fixes for bionary packages
  • Loading branch information
ad3002 committed Aug 24, 2015
2 parents 3d11507 + 8194250 commit 4d5540a
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 18 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ Cookiecutter is designed for use on Linux/UNIX and OS X systems.

## Installation

You may install Cookiecutter from a binary package or compile it from
source codes.

### Binary package

Unpack the downloaded archive using tar:

```
tar -xvzf cookiecutter_osx.tar.gz
```

Executable files are located in the `bin` subdirectory. You may
either launch Cookiecutter from the directory to which the archive was
unpacked or copy executable files to any directory specified in the
`PATH` variable of your environment.

### Source codes

The package should be compiled from its source code using the
provided Makefile in the following way.

Expand Down
55 changes: 55 additions & 0 deletions create_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -eu
set -o pipefail

if [ $# -lt 1 ]; then
echo Please specify the output file name.
echo For example: ./create_package ~/Desktop/cookiecutter_osx.tar.gz
exit 1
fi

OUTPUT_FILE="$1"
PACKAGE_NAME=$( basename "$OUTPUT_FILE" )
PACKAGE_NAME=$( echo "$PACKAGE_NAME" | sed "s/\..*//" )

TEMPDIR=$( mktemp -d "/tmp/${PACKAGE_NAME}.XXXXXX" ) || exit 1

# compile binary files
cd src
make
cd ..

# copy executable files
mkdir "${TEMPDIR}/bin"
for FILE in cookiecutter extract remove separate rm_reads; do
cp "./src/${FILE}" "${TEMPDIR}/bin/${FILE}"
done

# copy demo and data directories
for DIR in data demo; do
cp -R "$DIR" "${TEMPDIR}/${DIR}"
done

# adjust the path for executable files in the demo script
sed -i "s#default='.'#default='..\/bin/'#" \
${TEMPDIR}/demo/run_demo_analysis.py

# copy LICENSE and README files
for FILE in LICENSE README.md; do
cp "$FILE" "${TEMPDIR}/${FILE}"
done

# create a gzipped TAR archive
TEMPFILE=$( tempfile )
tar -C "/tmp" -cvf "${TEMPFILE}.tar" $( basename "$TEMPDIR" )
gzip -9 "${TEMPFILE}.tar"
mv "${TEMPFILE}.tar.gz" "$OUTPUT_FILE"

# remove compiled files
cd src
make clean
cd ..

rm -r "$TEMPDIR"

15 changes: 10 additions & 5 deletions demo/run_demo_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@
parser.add_argument('-c', '--clear', action='store_true',
help='remove files created by the demo')

parser.add_argument('-e', '--executable', default='.',
help='the path to the Cookiecutter executable '
'file')

args = parser.parse_args()

fastq_file1 = args.fastq1
fastq_file2 = args.fastq2

data = {
"cookiecutter": os.path.join(args.executable, 'cookiecutter'),
"fastq1": fastq_file1,
"fastq2": fastq_file2,
"output_dir_1a": "../demo/temp_results_remove",
Expand All @@ -54,16 +59,16 @@
e='removing alpha satDNA')

command_launches = dict(
a='cookiecutter remove -1 %(fastq1)s -2 %(fastq2)s -o %('
a='%(cookiecutter)s remove -1 %(fastq1)s -2 %(fastq2)s -o %('
'output_dir_1a)s --fragments ../data/illumina.dat',
b='cookiecutter rm_reads -1 %(fastq1)s -2 %(fastq2)s -o %('
b='%(cookiecutter)s rm_reads -1 %(fastq1)s -2 %(fastq2)s -o %('
'output_dir_1b)s --polygc 13 --length 50 --fragments '
'../data/illumina.dat --dust_cutoff 3 --dust_k 4 --dust',
c='cookiecutter remove -i %(fastq1)s -o %('
c='%(cookiecutter)s remove -i %(fastq1)s -o %('
'output_dir_1c)s --fragments ../data/rdna.dat',
d='cookiecutter extract -1 %(fastq1)s -2 %(fastq2)s -o %('
d='%(cookiecutter)s extract -1 %(fastq1)s -2 %(fastq2)s -o %('
'output_dir_1d)s --fragments ../data/mtdna.dat',
e='cookiecutter separate -1 %(fastq1)s -2 %(fastq2)s -o %('
e='%(cookiecutter)s separate -1 %(fastq1)s -2 %(fastq2)s -o %('
'output_dir_1e)s --fragments ../data/alpha.dat'
)

Expand Down
24 changes: 11 additions & 13 deletions src/cookiecutter
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,14 @@ def verify_binaries():
Check if Cookiecutter binaries are present in the same directory
that contains the wrapper script.
"""
for i in program_names.itervalues():
path = os.path.join(os.path.dirname(os.path.realpath(
__file__)), i)
if not os.path.isfile(path) or not os.access(path, os.X_OK):
return False

wrapper_path = os.path.dirname(os.path.realpath(__file__))
# if binaries are present in the PATH directory, mofity the way
# they are called

for i in program_names.keys():
if not is_path_binary(program_names[i]):
program_names[i] = os.path.join(wrapper_path,
program_names[i])
path = os.path.join(wrapper_path, program_names[i])
if not os.path.isfile(path) or not os.access(path, os.X_OK):
return False
else:
program_names[i] = path

return True

Expand Down Expand Up @@ -717,8 +712,11 @@ def cookiecutter():

if __name__ == '__main__':
if not verify_binaries():
message = 'Missing Cookiecutter binaries, please ' \
'install the program using \'make && make ' \
message = 'Error: missing Cookiecutter binaries! If you use a ' \
'binary package, please check that all executable ' \
'files are in the same directory with ' \
'cookiecutter. If you downloaded source codes, ' \
'please install the program using \'make && make ' \
'install\' or launch it in the source ' \
'directory after running \'make\'. If you do not have ' \
'privileges to install to the system directory, you may ' \
Expand Down

0 comments on commit 4d5540a

Please sign in to comment.