diff --git a/configure b/configure index 0572fa3..40e1729 100755 --- a/configure +++ b/configure @@ -1,13 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for libplinkio 0.2.4. +# Generated by GNU Autoconf 2.69 for libplinkio 0.2.4. # # Report bugs to . # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -136,6 +134,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -169,7 +192,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -222,21 +246,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -339,6 +367,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -460,6 +496,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -494,16 +534,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -515,28 +555,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -1219,8 +1239,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1483,9 +1501,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libplinkio configure 0.2.4 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1561,7 +1579,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1906,7 +1924,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libplinkio $as_me 0.2.4, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2321,7 +2339,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2490,7 +2508,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2530,7 +2548,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2581,7 +2599,7 @@ do test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -2634,7 +2652,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2786,7 +2804,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2826,7 +2844,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2879,7 +2897,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2920,7 +2938,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2978,7 +2996,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3022,7 +3040,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3468,8 +3486,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4066,7 +4083,7 @@ do for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue + as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in @@ -4142,7 +4159,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4208,7 +4225,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4275,7 +4292,7 @@ do for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue + as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in @@ -4531,7 +4548,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4575,7 +4592,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4994,7 +5011,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5034,7 +5051,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5340,7 +5357,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5380,7 +5397,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5484,7 +5501,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5528,7 +5545,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5653,7 +5670,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5693,7 +5710,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5752,7 +5769,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5792,7 +5809,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6427,7 +6444,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6467,7 +6484,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6547,7 +6564,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6587,7 +6604,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6639,7 +6656,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6679,7 +6696,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6731,7 +6748,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6771,7 +6788,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6823,7 +6840,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6863,7 +6880,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6915,7 +6932,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6955,7 +6972,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11463,7 +11480,7 @@ if ${am_cv_pathless_PYTHON+:} false; then : $as_echo_n "(cached) " >&6 else - for am_cv_pathless_PYTHON in python python2 python3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do + for am_cv_pathless_PYTHON in python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do test "$am_cv_pathless_PYTHON" = none && break prog="import sys # split strings by '.' and convert to numeric. Append some zeros @@ -11507,7 +11524,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11678,7 +11695,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11857,11 +11874,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -11878,8 +11895,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -11895,10 +11913,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -12583,16 +12601,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -12652,28 +12670,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -12695,7 +12701,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by libplinkio $as_me 0.2.4, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -12752,10 +12758,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libplinkio config.status 0.2.4 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -12835,7 +12841,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/py-plinkio/cplinkio.c b/py-plinkio/cplinkio.c index 11629f6..d88ec63 100644 --- a/py-plinkio/cplinkio.c +++ b/py-plinkio/cplinkio.c @@ -128,14 +128,22 @@ plinkio_open(PyObject *self, PyObject *args) return NULL; } int pio_open_status = pio_open( &plink_file, path ); - if( pio_open_status != PIO_OK ){ - if (pio_open_status == P_FAM_IO_ERROR){ + if( pio_open_status != PIO_OK ) + { + if( pio_open_status == P_FAM_IO_ERROR ) + { PyErr_SetString( PyExc_IOError, "Error while trying to open the FAM plink file." ); - } else if (pio_open_status == P_BIM_IO_ERROR){ + } + else if( pio_open_status == P_BIM_IO_ERROR ) + { PyErr_SetString( PyExc_IOError, "Error while trying to open the BIM plink file." ); - }else if (pio_open_status == P_BED_IO_ERROR){ + } + else if( pio_open_status == P_BED_IO_ERROR ) + { PyErr_SetString( PyExc_IOError, "Error while trying to open the BED plink file." ); - }else{ + } + else + { PyErr_SetString( PyExc_IOError, "Error while trying to open plink file." ); } return NULL; @@ -154,6 +162,167 @@ plinkio_open(PyObject *self, PyObject *args) return (PyObject *) c_plink_file; } +/** + * Creates a plink file and returns a handle to it. + * + * @param self - + * @param args First argument is a path to the plink file. Second argument + * is a list of Sample objects. + * + * @return A handle to the plink file, or throws an IOError. + */ +static PyObject * +plinkio_create(PyObject *self, PyObject *args) +{ + int i, sex, affection; + const char *path; + struct pio_sample_t *samples; + struct pio_file_t plink_file = { 0 }; + c_plink_file_t *c_plink_file; + PyObject *sample_list; + PyObject *sample_object; + PyObject *i_object; + + if( !PyArg_ParseTuple( args, "sO", &path, &sample_list ) ) + { + return NULL; + } + + samples = ( struct pio_sample_t * ) malloc( sizeof( struct pio_sample_t ) * PyObject_Size( sample_list ) ); + for(i = 0; i < PyObject_Size( sample_list ); i++) + { + i_object = PyInt_FromLong( i ); + sample_object = PyObject_GetItem( sample_list, i_object ); + samples[ i ].fid = PyString_AsString( PyObject_GetAttrString( sample_object, "fid" ) ); + samples[ i ].iid = PyString_AsString( PyObject_GetAttrString( sample_object, "iid" ) ); + samples[ i ].father_iid = PyString_AsString( PyObject_GetAttrString( sample_object, "father_iid" ) ); + samples[ i ].mother_iid = PyString_AsString( PyObject_GetAttrString( sample_object, "mother_iid" ) ); + samples[ i ].phenotype = PyFloat_AsDouble( PyObject_GetAttrString( sample_object, "phenotype" ) ) ; + + sex = PyInt_AsLong( PyObject_GetAttrString( sample_object, "sex" ) ); + if( sex == 0 ) + { + samples[ i ].sex = PIO_FEMALE; + } + else if( sex == 1 ) + { + samples[ i ].sex = PIO_MALE; + } + else + { + samples[ i ].sex = PIO_UNKNOWN; + } + + affection = PyInt_AsLong( PyObject_GetAttrString( sample_object, "affection" ) ); + if( affection == 0 ) + { + samples[ i ].affection = PIO_CONTROL; + } + else if( affection == 1 ) + { + samples[ i ].affection = PIO_CASE; + } + else if( affection == -9 ) + { + samples[ i ].affection = PIO_MISSING; + } + else + { + samples[ i ].affection = PIO_CONTINUOUS; + } + + Py_DECREF( i_object ); + } + + int pio_create_status = pio_create( &plink_file, path, samples, PyObject_Size( sample_list ) ); + if( pio_create_status != PIO_OK ) + { + free( samples ); + if( pio_create_status == P_FAM_IO_ERROR ) + { + PyErr_SetString( PyExc_IOError, "Error while trying to creating FAM file." ); + } + else if( pio_create_status == P_BIM_IO_ERROR ) + { + PyErr_SetString( PyExc_IOError, "Error while trying to creating BIM file." ); + } + else if( pio_create_status == P_BED_IO_ERROR ) + { + PyErr_SetString( PyExc_IOError, "Error while trying to creating BED file." ); + } + else + { + PyErr_SetString( PyExc_IOError, "Error while trying to creating plink file." ); + } + return NULL; + } + + c_plink_file = (c_plink_file_t *) c_plink_file_prototype.tp_alloc( &c_plink_file_prototype, 0 ); + c_plink_file->file = plink_file; + c_plink_file->row = (snp_t *) malloc( pio_row_size( &plink_file ) ); + c_plink_file->row_length = pio_num_samples( &plink_file ); + + free( samples ); + + return (PyObject *) c_plink_file; +} + +/** + * Writes a row to a created plink file. + * + * @param self - + * @param args First argument is the plink file. Second argument + * is a Locus object. Third argument is a list of genotypes. + * + * @return A handle to the plink file, or throws an IOError. + */ +static PyObject * +plinkio_write_row(PyObject *self, PyObject *args) +{ + PyObject *plink_file; + c_plink_file_t *c_plink_file; + PyObject *locus_object; + PyObject *genotypes; + PyObject *i_object; + struct pio_locus_t locus; + int i; + + if( !PyArg_ParseTuple( args, "O!OO", &c_plink_file_prototype, &plink_file, &locus_object, &genotypes ) ) + { + return NULL; + } + + c_plink_file = (c_plink_file_t *) plink_file; + if( PyObject_Size( genotypes ) != c_plink_file->row_length ) + { + PyErr_SetString( PyExc_ValueError, "Error, wrong number of genotypes given." ); + return NULL; + } + + locus.chromosome = PyInt_AsLong( PyObject_GetAttrString( locus_object, "chromosome" ) ); + locus.name = PyString_AsString( PyObject_GetAttrString( locus_object, "name" ) ); + locus.position = PyFloat_AsDouble( PyObject_GetAttrString( locus_object, "position" ) ); + locus.bp_position = PyInt_AsLong( PyObject_GetAttrString( locus_object, "bp_position" ) ); + locus.allele1 = PyString_AsString( PyObject_GetAttrString( locus_object, "allele1" ) ); + locus.allele2 = PyString_AsString( PyObject_GetAttrString( locus_object, "allele2" ) ); + + for(i = 0; i < c_plink_file->row_length; i++) + { + i_object = PyInt_FromLong( i ); + c_plink_file->row[ i ] = (snp_t) PyInt_AsLong( PyObject_GetItem( genotypes, i_object ) ); + + Py_DECREF( i_object ); + } + + if( pio_write_row( &c_plink_file->file, &locus, c_plink_file->row ) != PIO_OK ) + { + PyErr_SetString( PyExc_IOError, "Error while writing to plink file." ); + return NULL; + } + + Py_RETURN_NONE; +} + /** * Reads a row of SNPs from the bed, advances the file pointer, * returns the snps as a list, where the SNPs are encoded as in @@ -287,7 +456,7 @@ plinkio_get_samples(PyObject *self, PyObject *args) { PyObject *plink_file; c_plink_file_t *c_plink_file; - int i; + int i, sex, affection; if( !PyArg_ParseTuple( args, "O!", &c_plink_file_prototype, &plink_file ) ) { @@ -313,13 +482,33 @@ plinkio_get_samples(PyObject *self, PyObject *args) { struct pio_sample_t *sample = pio_get_sample( &c_plink_file->file, i ); + sex = 0; + if( sample->sex == PIO_MALE ) + { + sex = 1; + } + else if( sample->sex != PIO_FEMALE ) + { + sex = -9; + } + + affection = 0; + if( sample->affection == PIO_CASE ) + { + affection = 1; + } + else if( sample->affection != PIO_CONTROL ) + { + affection = -9; + } + PyObject *args = Py_BuildValue( "ssssiif", sample->fid, sample->iid, sample->father_iid, sample->mother_iid, - (int) sample->sex, - (int) sample->affection, + sex, + affection, sample->phenotype ); PyObject *pySample = PyObject_CallObject( sampleClass, args ); @@ -412,6 +601,8 @@ static PyMethodDef plinkio_methods[] = { "one_locus_per_row", plinkio_one_locus_per_row, METH_VARARGS, "Returns true if a row contains the snps for a single locus." }, { "close", plinkio_close, METH_VARARGS, "Close a plink file." }, { "transpose", plinkio_transpose, METH_VARARGS, "Transposes the plink file." }, + { "create", plinkio_create, METH_VARARGS, "Creates a new plink file." }, + { "write_row", plinkio_write_row, METH_VARARGS, "Writes genotypes to a created plink file." }, { NULL } }; diff --git a/py-plinkio/wrapper/plinkfile.py b/py-plinkio/wrapper/plinkfile.py index 1c87787..8e82e4a 100644 --- a/py-plinkio/wrapper/plinkfile.py +++ b/py-plinkio/wrapper/plinkfile.py @@ -81,6 +81,54 @@ def close(self): def transpose(self, new_path): return cplinkio.transpose( self.path, new_path ) +class WritablePlinkFile: + ## + # Creates the plink file at the given path containing the given + # samples. Their genotypes can then be written one row at a time. + # This file may not be read simulatenously. + # + # @param path The prefix for a .bed, .fam and .bim without + # the extension. E.g. for the files /plink/myfile.fam, + # /plink/myfile.bim, /plink/myfile.bed use the path + # /plink/myfile + # @param samples A list of Sample objects which are the final subjects + # that will be in the file. + # + def __init__(self, path, samples): + self.path = path + self.handle = cplinkio.create( path, samples ) + + ## + # Returns a list of the samples. + # + def get_samples(self): + return cplinkio.get_samples( self.handle ) + + ## + # Returns a list of the loci. + # + def get_loci(self): + return cplinkio.get_loci( self.handle ) + + ## + # Takes a locus and the corresponding genotypes and + # writes them to the plink file. + # + # @param locus A Locus object to write. + # @param row An indexable list of genotypes. + # + def write_row(self, locus, row): + return cplinkio.write_row( self.handle, locus, row ) + + ## + # Closes the file. + # + def close(self): + if self.handle: + cplinkio.close( self.handle ) + self.handle = None + + class Sample: def __init__(self, fid, iid, father_iid, mother_iid, sex, affection, phenotype = 0.0): ## @@ -167,3 +215,15 @@ def __str__(self): # def open(path): return PlinkFile( path ) + +## +# Creates a new plink file based on the given samples. +# +# @param path The prefix for a .bed, .fam and .bim without +# the extension. E.g. for the files /plink/myfile.fam, +# /plink/myfile.bim, /plink/myfile.bed use the path +# /plink/myfile +# @param samples A list of Sample objects to write to the file. +# +def create(path, samples): + return WritablePlinkFile( path, samples ) diff --git a/src/bed.c b/src/bed.c index 05b6e70..fb5aae8 100644 --- a/src/bed.c +++ b/src/bed.c @@ -112,6 +112,31 @@ unpack_snps(const snp_t *packed_snps, unsigned char *unpacked_snps, size_t num_c } } +/** + * Does the reverse of unpack_snps, and packs SNPs into bytes. See unpack_snps for + * the detailed format. + * + * @param unpack_snps The unpacked SNPs. + * @param packed_snps The packed SNPs. + * @param num_cols The number of columns. + */ +void +pack_snps(const snp_t *unpacked_snps, unsigned char *packed_snps, size_t num_cols) +{ + int i; + int packed_index; + int position_in_byte; + + bzero( packed_snps, num_cols / 4 + 1 ); + for(i = 0; i < num_cols; i++) + { + /* Genotypes are stored backwards. */ + packed_index = i / 4; + position_in_byte = (i % 4) * 2; + packed_snps[ packed_index ] |= ( snp_to_bits[ unpacked_snps[ i ] ] << position_in_byte ); + } +} + /** * Transposes the given memory mapped file in place. * @@ -231,6 +256,61 @@ bed_open(struct pio_bed_file_t *bed_file, const char *path, size_t num_loci, siz return PIO_OK; } +pio_status_t +bed_create(struct pio_bed_file_t *bed_file, const char *path, size_t num_samples) +{ + FILE *bed_fp; + unsigned char header_bytes[3]; + int length; + int row_size_bytes; + + bzero( bed_file, sizeof( *bed_file ) ); + bed_fp = fopen( path, "w" ); + if( bed_fp == NULL ) + { + return PIO_ERROR; + } + + bed_file->fp = bed_fp; + bed_file->header = bed_header_init( 0, num_samples ); + bed_header_to_bytes( &bed_file->header, header_bytes, &length ); + if( fwrite( header_bytes, sizeof( unsigned char ), length, bed_fp ) <= 0 ) + { + fclose( bed_fp ); + return PIO_ERROR; + } + + row_size_bytes = bed_header_row_size( &bed_file->header ); + bed_file->read_buffer = ( snp_t * ) malloc( row_size_bytes ); + bed_file->cur_row = 0; + + return PIO_OK; +} + +pio_status_t +bed_write_row(struct pio_bed_file_t *bed_file, snp_t *buffer) +{ + int row_size_bytes; + int bytes_written; + + pack_snps( buffer, bed_file->read_buffer, bed_header_num_cols( &bed_file->header ) ); + row_size_bytes = bed_header_row_size( &bed_file->header ); + + bytes_written = fwrite( bed_file->read_buffer, sizeof( unsigned char ), row_size_bytes, bed_file->fp ); + + if( bytes_written > 0 ) + { + bed_file->header.num_loci += 1; + bed_file->cur_row += 1; + + return PIO_OK; + } + else + { + return PIO_ERROR; + } +} + pio_status_t bed_read_row(struct pio_bed_file_t *bed_file, snp_t *buffer) { diff --git a/src/bim.c b/src/bim.c index bd0a270..2aa89c7 100644 --- a/src/bim.c +++ b/src/bim.c @@ -75,6 +75,46 @@ bim_open(struct pio_bim_file_t *bim_file, const char *path) return status; } +pio_status_t +bim_create(struct pio_bim_file_t *bim_file, const char *path) +{ + FILE *bim_fp; + bzero( bim_file, sizeof( *bim_file ) ); + bim_fp = fopen( path, "w" ); + if( bim_fp == NULL ) + { + return PIO_ERROR; + } + + bim_file->fp = bim_fp; + utarray_new( bim_file->locus, &LOCUS_ICD ); + + return PIO_OK; +} + +pio_status_t +bim_write(struct pio_bim_file_t *bim_file, struct pio_locus_t *locus) +{ + struct pio_locus_t locus_copy; + if( write_locus( bim_file->fp, locus ) == PIO_OK ) + { + locus_copy.pio_id = bim_num_loci( bim_file ); + locus_copy.chromosome = locus->chromosome; + locus_copy.name = strdup( locus->name ); + locus_copy.position = locus->position; + locus_copy.bp_position = locus->bp_position; + locus_copy.allele1 = strdup( locus->allele1 ); + locus_copy.allele2 = strdup( locus->allele2 ); + + utarray_push_back( bim_file->locus, &locus_copy ); + return PIO_OK; + } + else + { + return PIO_ERROR; + } +} + struct pio_locus_t * bim_get_locus(struct pio_bim_file_t *bim_file, size_t pio_id) { @@ -94,6 +134,10 @@ bim_close(struct pio_bim_file_t *bim_file) { return; } + if( bim_file->fp != NULL ) + { + fclose( bim_file->fp ); + } utarray_free( bim_file->locus ); bim_file->locus = NULL; diff --git a/src/bim_parse.c b/src/bim_parse.c index 0fd0775..248ff92 100644 --- a/src/bim_parse.c +++ b/src/bim_parse.c @@ -282,3 +282,26 @@ parse_loci(FILE *bim_fp, UT_array *locus) return ( state.any_error == 0 ) ? PIO_OK : PIO_ERROR; } + +pio_status_t +write_locus(FILE *bim_fp, struct pio_locus_t *locus) +{ + int bytes_written = fprintf( bim_fp, + "%d\t%s\t%f\t%lld\t%s\t%s\n", + locus->chromosome, + locus->name, + locus->position, + locus->bp_position, + locus->allele1, + locus->allele2 + ); + + if( bytes_written > 0 ) + { + return PIO_OK; + } + else + { + return PIO_ERROR; + } +} diff --git a/src/fam.c b/src/fam.c index 4a2393d..15b15c5 100644 --- a/src/fam.c +++ b/src/fam.c @@ -84,6 +84,45 @@ fam_open(struct pio_fam_file_t *fam_file, const char *path) return status; } +pio_status_t +fam_create(struct pio_fam_file_t *fam_file, const char *path, struct pio_sample_t *samples, size_t num_samples) +{ + int i; + FILE *fam_fp; + struct pio_sample_t sample_copy; + + bzero( fam_file, sizeof( *fam_file ) ); + fam_fp = fopen( path, "w" ); + if( fam_fp == NULL ) + { + return PIO_ERROR; + } + + fam_file->fp = fam_fp; + + utarray_new( fam_file->sample, &SAMPLE_ICD ); + for(i = 0; i < num_samples; i++) + { + if( write_sample( fam_fp, &samples[ i ] ) != PIO_OK ) + { + return PIO_ERROR; + } + + sample_copy.pio_id = i; + sample_copy.fid = strdup( samples[ i ].fid ); + sample_copy.iid = strdup( samples[ i ].iid ); + sample_copy.mother_iid = strdup( samples[ i ].mother_iid ); + sample_copy.father_iid = strdup( samples[ i ].father_iid ); + sample_copy.sex = samples[ i ].sex; + sample_copy.affection = samples[ i ].affection; + sample_copy.phenotype = samples[ i ].phenotype; + + utarray_push_back( fam_file->sample, &sample_copy ); + } + + return PIO_OK; +} + struct pio_sample_t * fam_get_sample(struct pio_fam_file_t *fam_file, size_t pio_id) { @@ -103,6 +142,10 @@ fam_close(struct pio_fam_file_t *fam_file) { return; } + if( fam_file->fp != NULL ) + { + fclose( fam_file->fp ); + } utarray_free( fam_file->sample ); diff --git a/src/fam_parse.c b/src/fam_parse.c index 4947cbc..496dbf9 100644 --- a/src/fam_parse.c +++ b/src/fam_parse.c @@ -105,7 +105,7 @@ parse_iid(const char *field, size_t length, pio_status_t *status) * @param length Length of the field. * @param status Status of the conversion. * - * @return The parsed csv field, or PIO_UNKOWN along with + * @return The parsed csv field, or PIO_UNKNOWN along with * status = PIO_ERROR if it could not be parsed. */ static enum sex_t @@ -114,7 +114,7 @@ parse_sex(const char *field, size_t length, pio_status_t *status) if( length != 1 ) { *status = PIO_ERROR; - return PIO_UNKOWN; + return PIO_UNKNOWN; } *status = PIO_OK; @@ -128,7 +128,7 @@ parse_sex(const char *field, size_t length, pio_status_t *status) } else { - return PIO_UNKOWN; + return PIO_UNKNOWN; } } @@ -306,3 +306,61 @@ parse_samples(FILE *fam_fp, UT_array *sample) return ( state.any_error == 0 ) ? PIO_OK : PIO_ERROR; } + + +pio_status_t +write_sample(FILE *fam_fp, struct pio_sample_t *sample) +{ + int sex = 0; + if( sample->sex == PIO_MALE ) + { + sex = 1; + } + else if( sample->sex == PIO_FEMALE ) + { + sex = 2; + } + + int bytes_written = 0; + if( sample->affection == PIO_CONTINUOUS ) + { + bytes_written = fprintf( fam_fp, + "%s\t%s\t%s\t%s\t%d\t%f\n", + sample->fid, + sample->iid, + sample->father_iid, + sample->mother_iid, + sex, + sample->phenotype ); + } + else + { + int affection = 0; + if( sample->affection == PIO_CONTROL ) + { + affection = 1; + } + else if( sample->affection == PIO_CASE ) + { + affection = 2; + } + + bytes_written = fprintf( fam_fp, + "%s\t%s\t%s\t%s\t%d\t%d\n", + sample->fid, + sample->iid, + sample->father_iid, + sample->mother_iid, + sex, + affection ); + } + + if( bytes_written > 0 ) + { + return PIO_OK; + } + else + { + return PIO_ERROR; + } +} diff --git a/src/plinkio.c b/src/plinkio.c index 13b6588..3e5ec46 100644 --- a/src/plinkio.c +++ b/src/plinkio.c @@ -98,6 +98,49 @@ pio_status_t pio_open_ex(struct pio_file_t *plink_file, const char *fam_path, co } } +pio_status_t +pio_create(struct pio_file_t *plink_file, const char *plink_file_prefix, struct pio_sample_t *samples, size_t num_samples) +{ + int error = 0; + + char *fam_path = concatenate( plink_file_prefix, ".fam" ); + char *bim_path = concatenate( plink_file_prefix, ".bim" ); + char *bed_path = concatenate( plink_file_prefix, ".bed" ); + + if( fam_create( &plink_file->fam_file, fam_path, samples, num_samples ) != PIO_OK ) + { + return P_FAM_IO_ERROR; + } + if( bim_create( &plink_file->bim_file, bim_path ) ) + { + return P_BIM_IO_ERROR; + } + if( bed_create( &plink_file->bed_file, bed_path, num_samples ) ) + { + return P_BED_IO_ERROR; + } +} + +pio_status_t +pio_write_row(struct pio_file_t *plink_file, struct pio_locus_t *locus, snp_t *buffer) +{ + pio_status_t status_bim = bim_write( &plink_file->bim_file, locus ); + pio_status_t status_bed = bed_write_row( &plink_file->bed_file, buffer ); + + if( status_bim != PIO_OK ) + { + return P_BIM_IO_ERROR; + } + else if( status_bed != PIO_OK ) + { + return P_BED_IO_ERROR; + } + else + { + return PIO_OK; + } +} + struct pio_sample_t * pio_get_sample(struct pio_file_t *plink_file, size_t pio_id) { diff --git a/src/plinkio/bed.h b/src/plinkio/bed.h index 7fe2af0..bf988d9 100644 --- a/src/plinkio/bed.h +++ b/src/plinkio/bed.h @@ -63,6 +63,26 @@ struct pio_bed_file_t */ pio_status_t bed_open(struct pio_bed_file_t *bed_file, const char *path, size_t num_loci, size_t num_samples); +/** + * Creates a bed file. + * + * @param bed_file Bed file. + * @param path Path to the bed file. + * @param num_samples The number of samples that the .bed file will include. + * + * @return PIO_OK if the file could be created, PIO_ERROR otherwise. + */ +pio_status_t bed_create(struct pio_bed_file_t *bed_file, const char *path, size_t num_samples); + +/** + * Writes a single row of samples to the bed file, assuming that the size of + * the buffer is at least as big as specified when created. + * + * @param bed_file Bed file. + * @param buffer List of SNPs to write to file. + */ +pio_status_t bed_write_row(struct pio_bed_file_t *bed_file, snp_t *buffer); + /** * Reads a single row from the given bed_file. Each element in the buffer * will contain a SNP. The SNP will be encoded as follows: diff --git a/src/plinkio/bim.h b/src/plinkio/bim.h index 58cc7aa..621a09a 100644 --- a/src/plinkio/bim.h +++ b/src/plinkio/bim.h @@ -86,6 +86,26 @@ struct pio_bim_file_t */ pio_status_t bim_open(struct pio_bim_file_t *bim_file, const char *path); +/** + * Creates a new bim file at the given path. + * + * @param bim_file Bim file. + * @param path The location of the bim file. + * + * @return PIO_OK if the file could be created, PIO_ERROR otherwise. + */ +pio_status_t bim_create(struct pio_bim_file_t *bim_file, const char *path); + +/** + * Writes the given locus to the bim file. + * + * @param bim_file Bim file. + * @param locus The locus to write to the bim file. + * + * @return PIO_OK if the locus could be written, PIO_ERROR otherwise. + */ +pio_status_t bim_write(struct pio_bim_file_t *bim_file, struct pio_locus_t *locus); + /** * Returns the locus with the given pio_id. * diff --git a/src/plinkio/bim_parse.h b/src/plinkio/bim_parse.h index 7a395ed..30ca540 100644 --- a/src/plinkio/bim_parse.h +++ b/src/plinkio/bim_parse.h @@ -27,6 +27,17 @@ extern "C" { */ pio_status_t parse_loci(FILE *bim_fp, UT_array *locus); +/** + * Writes a single locus to the .bim file. + * + * @param bim_fp The .bim file to write to. + * @param locus The locus to write. + * + * @return PIO_OK if the locus was successfully written, + * PIO_ERROR otherwise. + */ +pio_status_t write_locus(FILE *bim_fp, struct pio_locus_t *locus); + #ifdef __cplusplus } #endif diff --git a/src/plinkio/fam.h b/src/plinkio/fam.h index e8175b5..6be32bf 100644 --- a/src/plinkio/fam.h +++ b/src/plinkio/fam.h @@ -25,7 +25,7 @@ enum sex_t { PIO_MALE, PIO_FEMALE, - PIO_UNKOWN + PIO_UNKNOWN }; /** @@ -115,6 +115,19 @@ struct pio_fam_file_t */ pio_status_t fam_open(struct pio_fam_file_t *fam_file, const char *path); +/** + * Creates a fam file at the given path, and writes all + * individuals to the file. + * + * @param fam_file Fam file. + * @param path The location of the fam file. + * @param samples List of samples. + * @param num_samples Number of samples in the list. + * + * @return PIO_OK if the file could be created and written, PIO_ERROR otherwise. + */ +pio_status_t fam_create(struct pio_fam_file_t *fam_file, const char *path, struct pio_sample_t *samples, size_t num_samples); + /** * Returns the sample with the given pio_id. * diff --git a/src/plinkio/fam_parse.h b/src/plinkio/fam_parse.h index feefd78..2583a1c 100644 --- a/src/plinkio/fam_parse.h +++ b/src/plinkio/fam_parse.h @@ -30,6 +30,14 @@ extern "C" { */ pio_status_t parse_samples(FILE *fam_fp, UT_array *sample); +/** + * Writes a sample to the .fam file. + * + * @param fam_fp Fam file. + * @param sample The sample to write. + */ +pio_status_t write_sample(FILE *fam_fp, struct pio_sample_t *sample); + #ifdef __cplusplus } #endif diff --git a/src/plinkio/plinkio.h b/src/plinkio/plinkio.h index c9153b3..283a5a6 100644 --- a/src/plinkio/plinkio.h +++ b/src/plinkio/plinkio.h @@ -57,6 +57,31 @@ struct pio_file_t */ pio_status_t pio_open(struct pio_file_t *plink_file, const char *plink_file_prefix); +/** + * Creates a new binary plink file. + * + * @param plink_file Plink file to create. + * @param plink_file_prefix Path to plink file. + * @param samples Complete list of samples to be in the .fam file. This is required since + * we need to know the length of the rows in the bed file. + * @param num_samples The number of samples in the samples array. + * + * @return PIO_OK if all files could be created. PIO_ERROR otherwise. + */ +pio_status_t pio_create(struct pio_file_t *plink_file, const char *plink_file_prefix, struct pio_sample_t *samples, size_t num_samples); + +/** + * Writes the genotypes for a single SNP for all individuals to the .bed file, + * and adds the corresponding entry to the .bim file. + * + * @param plink_file Plink file created with pio_create. + * @param locus The locus to write genotypes for. + * @param buffer The genotypes for all individuals. + * + * @return PIO_OK if the files could be written. PIO_ERROR otherwise. + */ +pio_status_t pio_write_row(struct pio_file_t *plink_file, struct pio_locus_t *locus, snp_t *buffer); + /** * Opens the given plink file, which is specificed by separate paths * to the .bim, .bed and .fam files. diff --git a/src/plinkio/snp_lookup.h b/src/plinkio/snp_lookup.h index 6025158..aa25d03 100644 --- a/src/plinkio/snp_lookup.h +++ b/src/plinkio/snp_lookup.h @@ -21,6 +21,11 @@ extern "C" { #include #endif +/** + * Maps an unpacked snp to its corresponding bits. + */ +unsigned char snp_to_bits[] = { 0, 2, 3, 1 }; + /** * This files contains a lookup table that maps * SNPs packed in a single byte into an array of @@ -40,9 +45,9 @@ union snp_lookup_t }; #if __BYTE_ORDER == __LITTLE_ENDIAN -#include "snp_lookup_little.h" +#include #else -#include "snp_lookup_big.h" +#include #endif /* End test endianess */ #ifdef __cplusplus diff --git a/src/plinkio/snp_lookup_big.h b/src/plinkio/snp_lookup_big.h index ebc177e..cb98196 100644 --- a/src/plinkio/snp_lookup_big.h +++ b/src/plinkio/snp_lookup_big.h @@ -8,260 +8,260 @@ union snp_lookup_t snp_lookup[256] = { - {{2, 2, 2, 2}}, - {{2, 2, 2, 3}}, - {{2, 2, 2, 1}}, - {{2, 2, 2, 0}}, - {{2, 2, 3, 2}}, - {{2, 2, 3, 3}}, - {{2, 2, 3, 1}}, - {{2, 2, 3, 0}}, - {{2, 2, 1, 2}}, - {{2, 2, 1, 3}}, - {{2, 2, 1, 1}}, - {{2, 2, 1, 0}}, - {{2, 2, 0, 2}}, - {{2, 2, 0, 3}}, - {{2, 2, 0, 1}}, - {{2, 2, 0, 0}}, - {{2, 3, 2, 2}}, - {{2, 3, 2, 3}}, - {{2, 3, 2, 1}}, - {{2, 3, 2, 0}}, - {{2, 3, 3, 2}}, - {{2, 3, 3, 3}}, - {{2, 3, 3, 1}}, - {{2, 3, 3, 0}}, - {{2, 3, 1, 2}}, - {{2, 3, 1, 3}}, - {{2, 3, 1, 1}}, - {{2, 3, 1, 0}}, - {{2, 3, 0, 2}}, - {{2, 3, 0, 3}}, - {{2, 3, 0, 1}}, - {{2, 3, 0, 0}}, - {{2, 1, 2, 2}}, - {{2, 1, 2, 3}}, - {{2, 1, 2, 1}}, - {{2, 1, 2, 0}}, - {{2, 1, 3, 2}}, - {{2, 1, 3, 3}}, - {{2, 1, 3, 1}}, - {{2, 1, 3, 0}}, - {{2, 1, 1, 2}}, - {{2, 1, 1, 3}}, - {{2, 1, 1, 1}}, - {{2, 1, 1, 0}}, - {{2, 1, 0, 2}}, - {{2, 1, 0, 3}}, - {{2, 1, 0, 1}}, - {{2, 1, 0, 0}}, - {{2, 0, 2, 2}}, - {{2, 0, 2, 3}}, - {{2, 0, 2, 1}}, - {{2, 0, 2, 0}}, - {{2, 0, 3, 2}}, - {{2, 0, 3, 3}}, - {{2, 0, 3, 1}}, - {{2, 0, 3, 0}}, - {{2, 0, 1, 2}}, - {{2, 0, 1, 3}}, - {{2, 0, 1, 1}}, - {{2, 0, 1, 0}}, - {{2, 0, 0, 2}}, - {{2, 0, 0, 3}}, - {{2, 0, 0, 1}}, - {{2, 0, 0, 0}}, - {{3, 2, 2, 2}}, - {{3, 2, 2, 3}}, - {{3, 2, 2, 1}}, - {{3, 2, 2, 0}}, - {{3, 2, 3, 2}}, - {{3, 2, 3, 3}}, - {{3, 2, 3, 1}}, - {{3, 2, 3, 0}}, - {{3, 2, 1, 2}}, - {{3, 2, 1, 3}}, - {{3, 2, 1, 1}}, - {{3, 2, 1, 0}}, - {{3, 2, 0, 2}}, - {{3, 2, 0, 3}}, - {{3, 2, 0, 1}}, - {{3, 2, 0, 0}}, - {{3, 3, 2, 2}}, - {{3, 3, 2, 3}}, - {{3, 3, 2, 1}}, - {{3, 3, 2, 0}}, - {{3, 3, 3, 2}}, - {{3, 3, 3, 3}}, - {{3, 3, 3, 1}}, - {{3, 3, 3, 0}}, - {{3, 3, 1, 2}}, - {{3, 3, 1, 3}}, - {{3, 3, 1, 1}}, - {{3, 3, 1, 0}}, - {{3, 3, 0, 2}}, - {{3, 3, 0, 3}}, - {{3, 3, 0, 1}}, - {{3, 3, 0, 0}}, - {{3, 1, 2, 2}}, - {{3, 1, 2, 3}}, - {{3, 1, 2, 1}}, - {{3, 1, 2, 0}}, - {{3, 1, 3, 2}}, - {{3, 1, 3, 3}}, - {{3, 1, 3, 1}}, - {{3, 1, 3, 0}}, - {{3, 1, 1, 2}}, - {{3, 1, 1, 3}}, - {{3, 1, 1, 1}}, - {{3, 1, 1, 0}}, - {{3, 1, 0, 2}}, - {{3, 1, 0, 3}}, - {{3, 1, 0, 1}}, - {{3, 1, 0, 0}}, - {{3, 0, 2, 2}}, - {{3, 0, 2, 3}}, - {{3, 0, 2, 1}}, - {{3, 0, 2, 0}}, - {{3, 0, 3, 2}}, - {{3, 0, 3, 3}}, - {{3, 0, 3, 1}}, - {{3, 0, 3, 0}}, - {{3, 0, 1, 2}}, - {{3, 0, 1, 3}}, - {{3, 0, 1, 1}}, - {{3, 0, 1, 0}}, - {{3, 0, 0, 2}}, - {{3, 0, 0, 3}}, - {{3, 0, 0, 1}}, - {{3, 0, 0, 0}}, - {{1, 2, 2, 2}}, - {{1, 2, 2, 3}}, - {{1, 2, 2, 1}}, - {{1, 2, 2, 0}}, - {{1, 2, 3, 2}}, - {{1, 2, 3, 3}}, - {{1, 2, 3, 1}}, - {{1, 2, 3, 0}}, - {{1, 2, 1, 2}}, - {{1, 2, 1, 3}}, - {{1, 2, 1, 1}}, - {{1, 2, 1, 0}}, - {{1, 2, 0, 2}}, - {{1, 2, 0, 3}}, - {{1, 2, 0, 1}}, - {{1, 2, 0, 0}}, - {{1, 3, 2, 2}}, - {{1, 3, 2, 3}}, - {{1, 3, 2, 1}}, - {{1, 3, 2, 0}}, - {{1, 3, 3, 2}}, - {{1, 3, 3, 3}}, - {{1, 3, 3, 1}}, - {{1, 3, 3, 0}}, - {{1, 3, 1, 2}}, - {{1, 3, 1, 3}}, - {{1, 3, 1, 1}}, - {{1, 3, 1, 0}}, - {{1, 3, 0, 2}}, - {{1, 3, 0, 3}}, - {{1, 3, 0, 1}}, - {{1, 3, 0, 0}}, - {{1, 1, 2, 2}}, - {{1, 1, 2, 3}}, - {{1, 1, 2, 1}}, - {{1, 1, 2, 0}}, - {{1, 1, 3, 2}}, - {{1, 1, 3, 3}}, - {{1, 1, 3, 1}}, - {{1, 1, 3, 0}}, - {{1, 1, 1, 2}}, - {{1, 1, 1, 3}}, - {{1, 1, 1, 1}}, - {{1, 1, 1, 0}}, - {{1, 1, 0, 2}}, - {{1, 1, 0, 3}}, - {{1, 1, 0, 1}}, - {{1, 1, 0, 0}}, - {{1, 0, 2, 2}}, - {{1, 0, 2, 3}}, - {{1, 0, 2, 1}}, - {{1, 0, 2, 0}}, - {{1, 0, 3, 2}}, - {{1, 0, 3, 3}}, - {{1, 0, 3, 1}}, - {{1, 0, 3, 0}}, - {{1, 0, 1, 2}}, - {{1, 0, 1, 3}}, - {{1, 0, 1, 1}}, - {{1, 0, 1, 0}}, - {{1, 0, 0, 2}}, - {{1, 0, 0, 3}}, - {{1, 0, 0, 1}}, - {{1, 0, 0, 0}}, - {{0, 2, 2, 2}}, - {{0, 2, 2, 3}}, - {{0, 2, 2, 1}}, - {{0, 2, 2, 0}}, - {{0, 2, 3, 2}}, - {{0, 2, 3, 3}}, - {{0, 2, 3, 1}}, - {{0, 2, 3, 0}}, - {{0, 2, 1, 2}}, - {{0, 2, 1, 3}}, - {{0, 2, 1, 1}}, - {{0, 2, 1, 0}}, - {{0, 2, 0, 2}}, - {{0, 2, 0, 3}}, - {{0, 2, 0, 1}}, - {{0, 2, 0, 0}}, - {{0, 3, 2, 2}}, - {{0, 3, 2, 3}}, - {{0, 3, 2, 1}}, - {{0, 3, 2, 0}}, - {{0, 3, 3, 2}}, - {{0, 3, 3, 3}}, - {{0, 3, 3, 1}}, - {{0, 3, 3, 0}}, - {{0, 3, 1, 2}}, - {{0, 3, 1, 3}}, - {{0, 3, 1, 1}}, - {{0, 3, 1, 0}}, - {{0, 3, 0, 2}}, - {{0, 3, 0, 3}}, - {{0, 3, 0, 1}}, - {{0, 3, 0, 0}}, - {{0, 1, 2, 2}}, - {{0, 1, 2, 3}}, - {{0, 1, 2, 1}}, - {{0, 1, 2, 0}}, - {{0, 1, 3, 2}}, - {{0, 1, 3, 3}}, - {{0, 1, 3, 1}}, - {{0, 1, 3, 0}}, - {{0, 1, 1, 2}}, - {{0, 1, 1, 3}}, - {{0, 1, 1, 1}}, - {{0, 1, 1, 0}}, - {{0, 1, 0, 2}}, - {{0, 1, 0, 3}}, - {{0, 1, 0, 1}}, - {{0, 1, 0, 0}}, - {{0, 0, 2, 2}}, - {{0, 0, 2, 3}}, - {{0, 0, 2, 1}}, - {{0, 0, 2, 0}}, - {{0, 0, 3, 2}}, - {{0, 0, 3, 3}}, - {{0, 0, 3, 1}}, - {{0, 0, 3, 0}}, - {{0, 0, 1, 2}}, - {{0, 0, 1, 3}}, - {{0, 0, 1, 1}}, - {{0, 0, 1, 0}}, - {{0, 0, 0, 2}}, - {{0, 0, 0, 3}}, - {{0, 0, 0, 1}}, - {{0, 0, 0, 0}} + {{0, 0, 0, 0}}, + {{0, 0, 0, 3}}, + {{0, 0, 0, 1}}, + {{0, 0, 0, 2}}, + {{0, 0, 3, 0}}, + {{0, 0, 3, 3}}, + {{0, 0, 3, 1}}, + {{0, 0, 3, 2}}, + {{0, 0, 1, 0}}, + {{0, 0, 1, 3}}, + {{0, 0, 1, 1}}, + {{0, 0, 1, 2}}, + {{0, 0, 2, 0}}, + {{0, 0, 2, 3}}, + {{0, 0, 2, 1}}, + {{0, 0, 2, 2}}, + {{0, 3, 0, 0}}, + {{0, 3, 0, 3}}, + {{0, 3, 0, 1}}, + {{0, 3, 0, 2}}, + {{0, 3, 3, 0}}, + {{0, 3, 3, 3}}, + {{0, 3, 3, 1}}, + {{0, 3, 3, 2}}, + {{0, 3, 1, 0}}, + {{0, 3, 1, 3}}, + {{0, 3, 1, 1}}, + {{0, 3, 1, 2}}, + {{0, 3, 2, 0}}, + {{0, 3, 2, 3}}, + {{0, 3, 2, 1}}, + {{0, 3, 2, 2}}, + {{0, 1, 0, 0}}, + {{0, 1, 0, 3}}, + {{0, 1, 0, 1}}, + {{0, 1, 0, 2}}, + {{0, 1, 3, 0}}, + {{0, 1, 3, 3}}, + {{0, 1, 3, 1}}, + {{0, 1, 3, 2}}, + {{0, 1, 1, 0}}, + {{0, 1, 1, 3}}, + {{0, 1, 1, 1}}, + {{0, 1, 1, 2}}, + {{0, 1, 2, 0}}, + {{0, 1, 2, 3}}, + {{0, 1, 2, 1}}, + {{0, 1, 2, 2}}, + {{0, 2, 0, 0}}, + {{0, 2, 0, 3}}, + {{0, 2, 0, 1}}, + {{0, 2, 0, 2}}, + {{0, 2, 3, 0}}, + {{0, 2, 3, 3}}, + {{0, 2, 3, 1}}, + {{0, 2, 3, 2}}, + {{0, 2, 1, 0}}, + {{0, 2, 1, 3}}, + {{0, 2, 1, 1}}, + {{0, 2, 1, 2}}, + {{0, 2, 2, 0}}, + {{0, 2, 2, 3}}, + {{0, 2, 2, 1}}, + {{0, 2, 2, 2}}, + {{3, 0, 0, 0}}, + {{3, 0, 0, 3}}, + {{3, 0, 0, 1}}, + {{3, 0, 0, 2}}, + {{3, 0, 3, 0}}, + {{3, 0, 3, 3}}, + {{3, 0, 3, 1}}, + {{3, 0, 3, 2}}, + {{3, 0, 1, 0}}, + {{3, 0, 1, 3}}, + {{3, 0, 1, 1}}, + {{3, 0, 1, 2}}, + {{3, 0, 2, 0}}, + {{3, 0, 2, 3}}, + {{3, 0, 2, 1}}, + {{3, 0, 2, 2}}, + {{3, 3, 0, 0}}, + {{3, 3, 0, 3}}, + {{3, 3, 0, 1}}, + {{3, 3, 0, 2}}, + {{3, 3, 3, 0}}, + {{3, 3, 3, 3}}, + {{3, 3, 3, 1}}, + {{3, 3, 3, 2}}, + {{3, 3, 1, 0}}, + {{3, 3, 1, 3}}, + {{3, 3, 1, 1}}, + {{3, 3, 1, 2}}, + {{3, 3, 2, 0}}, + {{3, 3, 2, 3}}, + {{3, 3, 2, 1}}, + {{3, 3, 2, 2}}, + {{3, 1, 0, 0}}, + {{3, 1, 0, 3}}, + {{3, 1, 0, 1}}, + {{3, 1, 0, 2}}, + {{3, 1, 3, 0}}, + {{3, 1, 3, 3}}, + {{3, 1, 3, 1}}, + {{3, 1, 3, 2}}, + {{3, 1, 1, 0}}, + {{3, 1, 1, 3}}, + {{3, 1, 1, 1}}, + {{3, 1, 1, 2}}, + {{3, 1, 2, 0}}, + {{3, 1, 2, 3}}, + {{3, 1, 2, 1}}, + {{3, 1, 2, 2}}, + {{3, 2, 0, 0}}, + {{3, 2, 0, 3}}, + {{3, 2, 0, 1}}, + {{3, 2, 0, 2}}, + {{3, 2, 3, 0}}, + {{3, 2, 3, 3}}, + {{3, 2, 3, 1}}, + {{3, 2, 3, 2}}, + {{3, 2, 1, 0}}, + {{3, 2, 1, 3}}, + {{3, 2, 1, 1}}, + {{3, 2, 1, 2}}, + {{3, 2, 2, 0}}, + {{3, 2, 2, 3}}, + {{3, 2, 2, 1}}, + {{3, 2, 2, 2}}, + {{1, 0, 0, 0}}, + {{1, 0, 0, 3}}, + {{1, 0, 0, 1}}, + {{1, 0, 0, 2}}, + {{1, 0, 3, 0}}, + {{1, 0, 3, 3}}, + {{1, 0, 3, 1}}, + {{1, 0, 3, 2}}, + {{1, 0, 1, 0}}, + {{1, 0, 1, 3}}, + {{1, 0, 1, 1}}, + {{1, 0, 1, 2}}, + {{1, 0, 2, 0}}, + {{1, 0, 2, 3}}, + {{1, 0, 2, 1}}, + {{1, 0, 2, 2}}, + {{1, 3, 0, 0}}, + {{1, 3, 0, 3}}, + {{1, 3, 0, 1}}, + {{1, 3, 0, 2}}, + {{1, 3, 3, 0}}, + {{1, 3, 3, 3}}, + {{1, 3, 3, 1}}, + {{1, 3, 3, 2}}, + {{1, 3, 1, 0}}, + {{1, 3, 1, 3}}, + {{1, 3, 1, 1}}, + {{1, 3, 1, 2}}, + {{1, 3, 2, 0}}, + {{1, 3, 2, 3}}, + {{1, 3, 2, 1}}, + {{1, 3, 2, 2}}, + {{1, 1, 0, 0}}, + {{1, 1, 0, 3}}, + {{1, 1, 0, 1}}, + {{1, 1, 0, 2}}, + {{1, 1, 3, 0}}, + {{1, 1, 3, 3}}, + {{1, 1, 3, 1}}, + {{1, 1, 3, 2}}, + {{1, 1, 1, 0}}, + {{1, 1, 1, 3}}, + {{1, 1, 1, 1}}, + {{1, 1, 1, 2}}, + {{1, 1, 2, 0}}, + {{1, 1, 2, 3}}, + {{1, 1, 2, 1}}, + {{1, 1, 2, 2}}, + {{1, 2, 0, 0}}, + {{1, 2, 0, 3}}, + {{1, 2, 0, 1}}, + {{1, 2, 0, 2}}, + {{1, 2, 3, 0}}, + {{1, 2, 3, 3}}, + {{1, 2, 3, 1}}, + {{1, 2, 3, 2}}, + {{1, 2, 1, 0}}, + {{1, 2, 1, 3}}, + {{1, 2, 1, 1}}, + {{1, 2, 1, 2}}, + {{1, 2, 2, 0}}, + {{1, 2, 2, 3}}, + {{1, 2, 2, 1}}, + {{1, 2, 2, 2}}, + {{2, 0, 0, 0}}, + {{2, 0, 0, 3}}, + {{2, 0, 0, 1}}, + {{2, 0, 0, 2}}, + {{2, 0, 3, 0}}, + {{2, 0, 3, 3}}, + {{2, 0, 3, 1}}, + {{2, 0, 3, 2}}, + {{2, 0, 1, 0}}, + {{2, 0, 1, 3}}, + {{2, 0, 1, 1}}, + {{2, 0, 1, 2}}, + {{2, 0, 2, 0}}, + {{2, 0, 2, 3}}, + {{2, 0, 2, 1}}, + {{2, 0, 2, 2}}, + {{2, 3, 0, 0}}, + {{2, 3, 0, 3}}, + {{2, 3, 0, 1}}, + {{2, 3, 0, 2}}, + {{2, 3, 3, 0}}, + {{2, 3, 3, 3}}, + {{2, 3, 3, 1}}, + {{2, 3, 3, 2}}, + {{2, 3, 1, 0}}, + {{2, 3, 1, 3}}, + {{2, 3, 1, 1}}, + {{2, 3, 1, 2}}, + {{2, 3, 2, 0}}, + {{2, 3, 2, 3}}, + {{2, 3, 2, 1}}, + {{2, 3, 2, 2}}, + {{2, 1, 0, 0}}, + {{2, 1, 0, 3}}, + {{2, 1, 0, 1}}, + {{2, 1, 0, 2}}, + {{2, 1, 3, 0}}, + {{2, 1, 3, 3}}, + {{2, 1, 3, 1}}, + {{2, 1, 3, 2}}, + {{2, 1, 1, 0}}, + {{2, 1, 1, 3}}, + {{2, 1, 1, 1}}, + {{2, 1, 1, 2}}, + {{2, 1, 2, 0}}, + {{2, 1, 2, 3}}, + {{2, 1, 2, 1}}, + {{2, 1, 2, 2}}, + {{2, 2, 0, 0}}, + {{2, 2, 0, 3}}, + {{2, 2, 0, 1}}, + {{2, 2, 0, 2}}, + {{2, 2, 3, 0}}, + {{2, 2, 3, 3}}, + {{2, 2, 3, 1}}, + {{2, 2, 3, 2}}, + {{2, 2, 1, 0}}, + {{2, 2, 1, 3}}, + {{2, 2, 1, 1}}, + {{2, 2, 1, 2}}, + {{2, 2, 2, 0}}, + {{2, 2, 2, 3}}, + {{2, 2, 2, 1}}, + {{2, 2, 2, 2}}, }; diff --git a/src/plinkio/snp_lookup_little.h b/src/plinkio/snp_lookup_little.h index fc6b7b7..d0b282f 100644 --- a/src/plinkio/snp_lookup_little.h +++ b/src/plinkio/snp_lookup_little.h @@ -8,260 +8,260 @@ union snp_lookup_t snp_lookup[256] = { - {{2, 2, 2, 2}}, - {{3, 2, 2, 2}}, - {{1, 2, 2, 2}}, - {{0, 2, 2, 2}}, - {{2, 3, 2, 2}}, - {{3, 3, 2, 2}}, - {{1, 3, 2, 2}}, - {{0, 3, 2, 2}}, - {{2, 1, 2, 2}}, - {{3, 1, 2, 2}}, - {{1, 1, 2, 2}}, - {{0, 1, 2, 2}}, - {{2, 0, 2, 2}}, - {{3, 0, 2, 2}}, - {{1, 0, 2, 2}}, - {{0, 0, 2, 2}}, - {{2, 2, 3, 2}}, - {{3, 2, 3, 2}}, - {{1, 2, 3, 2}}, - {{0, 2, 3, 2}}, - {{2, 3, 3, 2}}, - {{3, 3, 3, 2}}, - {{1, 3, 3, 2}}, - {{0, 3, 3, 2}}, - {{2, 1, 3, 2}}, - {{3, 1, 3, 2}}, - {{1, 1, 3, 2}}, - {{0, 1, 3, 2}}, - {{2, 0, 3, 2}}, - {{3, 0, 3, 2}}, - {{1, 0, 3, 2}}, - {{0, 0, 3, 2}}, - {{2, 2, 1, 2}}, - {{3, 2, 1, 2}}, - {{1, 2, 1, 2}}, - {{0, 2, 1, 2}}, - {{2, 3, 1, 2}}, - {{3, 3, 1, 2}}, - {{1, 3, 1, 2}}, - {{0, 3, 1, 2}}, - {{2, 1, 1, 2}}, - {{3, 1, 1, 2}}, - {{1, 1, 1, 2}}, - {{0, 1, 1, 2}}, - {{2, 0, 1, 2}}, - {{3, 0, 1, 2}}, - {{1, 0, 1, 2}}, - {{0, 0, 1, 2}}, - {{2, 2, 0, 2}}, - {{3, 2, 0, 2}}, - {{1, 2, 0, 2}}, - {{0, 2, 0, 2}}, - {{2, 3, 0, 2}}, - {{3, 3, 0, 2}}, - {{1, 3, 0, 2}}, - {{0, 3, 0, 2}}, - {{2, 1, 0, 2}}, - {{3, 1, 0, 2}}, - {{1, 1, 0, 2}}, - {{0, 1, 0, 2}}, - {{2, 0, 0, 2}}, - {{3, 0, 0, 2}}, - {{1, 0, 0, 2}}, - {{0, 0, 0, 2}}, - {{2, 2, 2, 3}}, - {{3, 2, 2, 3}}, - {{1, 2, 2, 3}}, - {{0, 2, 2, 3}}, - {{2, 3, 2, 3}}, - {{3, 3, 2, 3}}, - {{1, 3, 2, 3}}, - {{0, 3, 2, 3}}, - {{2, 1, 2, 3}}, - {{3, 1, 2, 3}}, - {{1, 1, 2, 3}}, - {{0, 1, 2, 3}}, - {{2, 0, 2, 3}}, - {{3, 0, 2, 3}}, - {{1, 0, 2, 3}}, - {{0, 0, 2, 3}}, - {{2, 2, 3, 3}}, - {{3, 2, 3, 3}}, - {{1, 2, 3, 3}}, - {{0, 2, 3, 3}}, - {{2, 3, 3, 3}}, - {{3, 3, 3, 3}}, - {{1, 3, 3, 3}}, - {{0, 3, 3, 3}}, - {{2, 1, 3, 3}}, - {{3, 1, 3, 3}}, - {{1, 1, 3, 3}}, - {{0, 1, 3, 3}}, - {{2, 0, 3, 3}}, - {{3, 0, 3, 3}}, - {{1, 0, 3, 3}}, - {{0, 0, 3, 3}}, - {{2, 2, 1, 3}}, - {{3, 2, 1, 3}}, - {{1, 2, 1, 3}}, - {{0, 2, 1, 3}}, - {{2, 3, 1, 3}}, - {{3, 3, 1, 3}}, - {{1, 3, 1, 3}}, - {{0, 3, 1, 3}}, - {{2, 1, 1, 3}}, - {{3, 1, 1, 3}}, - {{1, 1, 1, 3}}, - {{0, 1, 1, 3}}, - {{2, 0, 1, 3}}, - {{3, 0, 1, 3}}, - {{1, 0, 1, 3}}, - {{0, 0, 1, 3}}, - {{2, 2, 0, 3}}, - {{3, 2, 0, 3}}, - {{1, 2, 0, 3}}, - {{0, 2, 0, 3}}, - {{2, 3, 0, 3}}, - {{3, 3, 0, 3}}, - {{1, 3, 0, 3}}, - {{0, 3, 0, 3}}, - {{2, 1, 0, 3}}, - {{3, 1, 0, 3}}, - {{1, 1, 0, 3}}, - {{0, 1, 0, 3}}, - {{2, 0, 0, 3}}, - {{3, 0, 0, 3}}, - {{1, 0, 0, 3}}, - {{0, 0, 0, 3}}, - {{2, 2, 2, 1}}, - {{3, 2, 2, 1}}, - {{1, 2, 2, 1}}, - {{0, 2, 2, 1}}, - {{2, 3, 2, 1}}, - {{3, 3, 2, 1}}, - {{1, 3, 2, 1}}, - {{0, 3, 2, 1}}, - {{2, 1, 2, 1}}, - {{3, 1, 2, 1}}, - {{1, 1, 2, 1}}, - {{0, 1, 2, 1}}, - {{2, 0, 2, 1}}, - {{3, 0, 2, 1}}, - {{1, 0, 2, 1}}, - {{0, 0, 2, 1}}, - {{2, 2, 3, 1}}, - {{3, 2, 3, 1}}, - {{1, 2, 3, 1}}, - {{0, 2, 3, 1}}, - {{2, 3, 3, 1}}, - {{3, 3, 3, 1}}, - {{1, 3, 3, 1}}, - {{0, 3, 3, 1}}, - {{2, 1, 3, 1}}, - {{3, 1, 3, 1}}, - {{1, 1, 3, 1}}, - {{0, 1, 3, 1}}, - {{2, 0, 3, 1}}, - {{3, 0, 3, 1}}, - {{1, 0, 3, 1}}, - {{0, 0, 3, 1}}, - {{2, 2, 1, 1}}, - {{3, 2, 1, 1}}, - {{1, 2, 1, 1}}, - {{0, 2, 1, 1}}, - {{2, 3, 1, 1}}, - {{3, 3, 1, 1}}, - {{1, 3, 1, 1}}, - {{0, 3, 1, 1}}, - {{2, 1, 1, 1}}, - {{3, 1, 1, 1}}, - {{1, 1, 1, 1}}, - {{0, 1, 1, 1}}, - {{2, 0, 1, 1}}, - {{3, 0, 1, 1}}, - {{1, 0, 1, 1}}, - {{0, 0, 1, 1}}, - {{2, 2, 0, 1}}, - {{3, 2, 0, 1}}, - {{1, 2, 0, 1}}, - {{0, 2, 0, 1}}, - {{2, 3, 0, 1}}, - {{3, 3, 0, 1}}, - {{1, 3, 0, 1}}, - {{0, 3, 0, 1}}, - {{2, 1, 0, 1}}, - {{3, 1, 0, 1}}, - {{1, 1, 0, 1}}, - {{0, 1, 0, 1}}, - {{2, 0, 0, 1}}, - {{3, 0, 0, 1}}, - {{1, 0, 0, 1}}, - {{0, 0, 0, 1}}, - {{2, 2, 2, 0}}, - {{3, 2, 2, 0}}, - {{1, 2, 2, 0}}, - {{0, 2, 2, 0}}, - {{2, 3, 2, 0}}, - {{3, 3, 2, 0}}, - {{1, 3, 2, 0}}, - {{0, 3, 2, 0}}, - {{2, 1, 2, 0}}, - {{3, 1, 2, 0}}, - {{1, 1, 2, 0}}, - {{0, 1, 2, 0}}, - {{2, 0, 2, 0}}, - {{3, 0, 2, 0}}, - {{1, 0, 2, 0}}, - {{0, 0, 2, 0}}, - {{2, 2, 3, 0}}, - {{3, 2, 3, 0}}, - {{1, 2, 3, 0}}, - {{0, 2, 3, 0}}, - {{2, 3, 3, 0}}, - {{3, 3, 3, 0}}, - {{1, 3, 3, 0}}, - {{0, 3, 3, 0}}, - {{2, 1, 3, 0}}, - {{3, 1, 3, 0}}, - {{1, 1, 3, 0}}, - {{0, 1, 3, 0}}, - {{2, 0, 3, 0}}, - {{3, 0, 3, 0}}, - {{1, 0, 3, 0}}, - {{0, 0, 3, 0}}, - {{2, 2, 1, 0}}, - {{3, 2, 1, 0}}, - {{1, 2, 1, 0}}, - {{0, 2, 1, 0}}, - {{2, 3, 1, 0}}, - {{3, 3, 1, 0}}, - {{1, 3, 1, 0}}, - {{0, 3, 1, 0}}, - {{2, 1, 1, 0}}, - {{3, 1, 1, 0}}, - {{1, 1, 1, 0}}, - {{0, 1, 1, 0}}, - {{2, 0, 1, 0}}, - {{3, 0, 1, 0}}, - {{1, 0, 1, 0}}, - {{0, 0, 1, 0}}, - {{2, 2, 0, 0}}, - {{3, 2, 0, 0}}, - {{1, 2, 0, 0}}, - {{0, 2, 0, 0}}, - {{2, 3, 0, 0}}, - {{3, 3, 0, 0}}, - {{1, 3, 0, 0}}, - {{0, 3, 0, 0}}, - {{2, 1, 0, 0}}, - {{3, 1, 0, 0}}, - {{1, 1, 0, 0}}, - {{0, 1, 0, 0}}, - {{2, 0, 0, 0}}, - {{3, 0, 0, 0}}, - {{1, 0, 0, 0}}, - {{0, 0, 0, 0}} + {{0, 0, 0, 0}}, + {{3, 0, 0, 0}}, + {{1, 0, 0, 0}}, + {{2, 0, 0, 0}}, + {{0, 3, 0, 0}}, + {{3, 3, 0, 0}}, + {{1, 3, 0, 0}}, + {{2, 3, 0, 0}}, + {{0, 1, 0, 0}}, + {{3, 1, 0, 0}}, + {{1, 1, 0, 0}}, + {{2, 1, 0, 0}}, + {{0, 2, 0, 0}}, + {{3, 2, 0, 0}}, + {{1, 2, 0, 0}}, + {{2, 2, 0, 0}}, + {{0, 0, 3, 0}}, + {{3, 0, 3, 0}}, + {{1, 0, 3, 0}}, + {{2, 0, 3, 0}}, + {{0, 3, 3, 0}}, + {{3, 3, 3, 0}}, + {{1, 3, 3, 0}}, + {{2, 3, 3, 0}}, + {{0, 1, 3, 0}}, + {{3, 1, 3, 0}}, + {{1, 1, 3, 0}}, + {{2, 1, 3, 0}}, + {{0, 2, 3, 0}}, + {{3, 2, 3, 0}}, + {{1, 2, 3, 0}}, + {{2, 2, 3, 0}}, + {{0, 0, 1, 0}}, + {{3, 0, 1, 0}}, + {{1, 0, 1, 0}}, + {{2, 0, 1, 0}}, + {{0, 3, 1, 0}}, + {{3, 3, 1, 0}}, + {{1, 3, 1, 0}}, + {{2, 3, 1, 0}}, + {{0, 1, 1, 0}}, + {{3, 1, 1, 0}}, + {{1, 1, 1, 0}}, + {{2, 1, 1, 0}}, + {{0, 2, 1, 0}}, + {{3, 2, 1, 0}}, + {{1, 2, 1, 0}}, + {{2, 2, 1, 0}}, + {{0, 0, 2, 0}}, + {{3, 0, 2, 0}}, + {{1, 0, 2, 0}}, + {{2, 0, 2, 0}}, + {{0, 3, 2, 0}}, + {{3, 3, 2, 0}}, + {{1, 3, 2, 0}}, + {{2, 3, 2, 0}}, + {{0, 1, 2, 0}}, + {{3, 1, 2, 0}}, + {{1, 1, 2, 0}}, + {{2, 1, 2, 0}}, + {{0, 2, 2, 0}}, + {{3, 2, 2, 0}}, + {{1, 2, 2, 0}}, + {{2, 2, 2, 0}}, + {{0, 0, 0, 3}}, + {{3, 0, 0, 3}}, + {{1, 0, 0, 3}}, + {{2, 0, 0, 3}}, + {{0, 3, 0, 3}}, + {{3, 3, 0, 3}}, + {{1, 3, 0, 3}}, + {{2, 3, 0, 3}}, + {{0, 1, 0, 3}}, + {{3, 1, 0, 3}}, + {{1, 1, 0, 3}}, + {{2, 1, 0, 3}}, + {{0, 2, 0, 3}}, + {{3, 2, 0, 3}}, + {{1, 2, 0, 3}}, + {{2, 2, 0, 3}}, + {{0, 0, 3, 3}}, + {{3, 0, 3, 3}}, + {{1, 0, 3, 3}}, + {{2, 0, 3, 3}}, + {{0, 3, 3, 3}}, + {{3, 3, 3, 3}}, + {{1, 3, 3, 3}}, + {{2, 3, 3, 3}}, + {{0, 1, 3, 3}}, + {{3, 1, 3, 3}}, + {{1, 1, 3, 3}}, + {{2, 1, 3, 3}}, + {{0, 2, 3, 3}}, + {{3, 2, 3, 3}}, + {{1, 2, 3, 3}}, + {{2, 2, 3, 3}}, + {{0, 0, 1, 3}}, + {{3, 0, 1, 3}}, + {{1, 0, 1, 3}}, + {{2, 0, 1, 3}}, + {{0, 3, 1, 3}}, + {{3, 3, 1, 3}}, + {{1, 3, 1, 3}}, + {{2, 3, 1, 3}}, + {{0, 1, 1, 3}}, + {{3, 1, 1, 3}}, + {{1, 1, 1, 3}}, + {{2, 1, 1, 3}}, + {{0, 2, 1, 3}}, + {{3, 2, 1, 3}}, + {{1, 2, 1, 3}}, + {{2, 2, 1, 3}}, + {{0, 0, 2, 3}}, + {{3, 0, 2, 3}}, + {{1, 0, 2, 3}}, + {{2, 0, 2, 3}}, + {{0, 3, 2, 3}}, + {{3, 3, 2, 3}}, + {{1, 3, 2, 3}}, + {{2, 3, 2, 3}}, + {{0, 1, 2, 3}}, + {{3, 1, 2, 3}}, + {{1, 1, 2, 3}}, + {{2, 1, 2, 3}}, + {{0, 2, 2, 3}}, + {{3, 2, 2, 3}}, + {{1, 2, 2, 3}}, + {{2, 2, 2, 3}}, + {{0, 0, 0, 1}}, + {{3, 0, 0, 1}}, + {{1, 0, 0, 1}}, + {{2, 0, 0, 1}}, + {{0, 3, 0, 1}}, + {{3, 3, 0, 1}}, + {{1, 3, 0, 1}}, + {{2, 3, 0, 1}}, + {{0, 1, 0, 1}}, + {{3, 1, 0, 1}}, + {{1, 1, 0, 1}}, + {{2, 1, 0, 1}}, + {{0, 2, 0, 1}}, + {{3, 2, 0, 1}}, + {{1, 2, 0, 1}}, + {{2, 2, 0, 1}}, + {{0, 0, 3, 1}}, + {{3, 0, 3, 1}}, + {{1, 0, 3, 1}}, + {{2, 0, 3, 1}}, + {{0, 3, 3, 1}}, + {{3, 3, 3, 1}}, + {{1, 3, 3, 1}}, + {{2, 3, 3, 1}}, + {{0, 1, 3, 1}}, + {{3, 1, 3, 1}}, + {{1, 1, 3, 1}}, + {{2, 1, 3, 1}}, + {{0, 2, 3, 1}}, + {{3, 2, 3, 1}}, + {{1, 2, 3, 1}}, + {{2, 2, 3, 1}}, + {{0, 0, 1, 1}}, + {{3, 0, 1, 1}}, + {{1, 0, 1, 1}}, + {{2, 0, 1, 1}}, + {{0, 3, 1, 1}}, + {{3, 3, 1, 1}}, + {{1, 3, 1, 1}}, + {{2, 3, 1, 1}}, + {{0, 1, 1, 1}}, + {{3, 1, 1, 1}}, + {{1, 1, 1, 1}}, + {{2, 1, 1, 1}}, + {{0, 2, 1, 1}}, + {{3, 2, 1, 1}}, + {{1, 2, 1, 1}}, + {{2, 2, 1, 1}}, + {{0, 0, 2, 1}}, + {{3, 0, 2, 1}}, + {{1, 0, 2, 1}}, + {{2, 0, 2, 1}}, + {{0, 3, 2, 1}}, + {{3, 3, 2, 1}}, + {{1, 3, 2, 1}}, + {{2, 3, 2, 1}}, + {{0, 1, 2, 1}}, + {{3, 1, 2, 1}}, + {{1, 1, 2, 1}}, + {{2, 1, 2, 1}}, + {{0, 2, 2, 1}}, + {{3, 2, 2, 1}}, + {{1, 2, 2, 1}}, + {{2, 2, 2, 1}}, + {{0, 0, 0, 2}}, + {{3, 0, 0, 2}}, + {{1, 0, 0, 2}}, + {{2, 0, 0, 2}}, + {{0, 3, 0, 2}}, + {{3, 3, 0, 2}}, + {{1, 3, 0, 2}}, + {{2, 3, 0, 2}}, + {{0, 1, 0, 2}}, + {{3, 1, 0, 2}}, + {{1, 1, 0, 2}}, + {{2, 1, 0, 2}}, + {{0, 2, 0, 2}}, + {{3, 2, 0, 2}}, + {{1, 2, 0, 2}}, + {{2, 2, 0, 2}}, + {{0, 0, 3, 2}}, + {{3, 0, 3, 2}}, + {{1, 0, 3, 2}}, + {{2, 0, 3, 2}}, + {{0, 3, 3, 2}}, + {{3, 3, 3, 2}}, + {{1, 3, 3, 2}}, + {{2, 3, 3, 2}}, + {{0, 1, 3, 2}}, + {{3, 1, 3, 2}}, + {{1, 1, 3, 2}}, + {{2, 1, 3, 2}}, + {{0, 2, 3, 2}}, + {{3, 2, 3, 2}}, + {{1, 2, 3, 2}}, + {{2, 2, 3, 2}}, + {{0, 0, 1, 2}}, + {{3, 0, 1, 2}}, + {{1, 0, 1, 2}}, + {{2, 0, 1, 2}}, + {{0, 3, 1, 2}}, + {{3, 3, 1, 2}}, + {{1, 3, 1, 2}}, + {{2, 3, 1, 2}}, + {{0, 1, 1, 2}}, + {{3, 1, 1, 2}}, + {{1, 1, 1, 2}}, + {{2, 1, 1, 2}}, + {{0, 2, 1, 2}}, + {{3, 2, 1, 2}}, + {{1, 2, 1, 2}}, + {{2, 2, 1, 2}}, + {{0, 0, 2, 2}}, + {{3, 0, 2, 2}}, + {{1, 0, 2, 2}}, + {{2, 0, 2, 2}}, + {{0, 3, 2, 2}}, + {{3, 3, 2, 2}}, + {{1, 3, 2, 2}}, + {{2, 3, 2, 2}}, + {{0, 1, 2, 2}}, + {{3, 1, 2, 2}}, + {{1, 1, 2, 2}}, + {{2, 1, 2, 2}}, + {{0, 2, 2, 2}}, + {{3, 2, 2, 2}}, + {{1, 2, 2, 2}}, + {{2, 2, 2, 2}}, }; diff --git a/tests/bed_test.c b/tests/bed_test.c index 2963af2..204f010 100644 --- a/tests/bed_test.c +++ b/tests/bed_test.c @@ -220,7 +220,7 @@ test_unpack_snps(void **state) { int i; /* packed_snps = [0, 1, 2, 3] */ - unsigned char packed_snps[] = { 0x4b }; + unsigned char packed_snps[] = { 0x78 }; snp_t unpacked_snps[4]; unpack_snps( packed_snps, unpacked_snps, 4 ); @@ -253,9 +253,9 @@ test_bed_read_row(void **state) struct pio_bed_file_t bed_file; /** * v 1.00 file containing only a header, and two snp rows = - * [0, 1, 2, 3] = 01001011 = 0x4b. + * [0, 1, 2, 3] = 0b01111000 = 0x78. */ - unsigned char file_data[] = { BED_V100_MAGIC1, BED_V100_MAGIC2, 0x01, 0x4b, 0x4b }; + unsigned char file_data[] = { BED_V100_MAGIC1, BED_V100_MAGIC2, 0x01, 0x78, 0x78 }; mock_init( file_data, 5 ); assert_int_equal( bed_open( &bed_file, "", 2, 4 ), PIO_OK ); diff --git a/tests/fam_test.c b/tests/fam_test.c index a6834be..d0c8ab5 100644 --- a/tests/fam_test.c +++ b/tests/fam_test.c @@ -37,7 +37,7 @@ test_parse_sex(void **state) { const char *TEST_STRING_MALE = "1"; const char *TEST_STRING_FEMALE = "2"; - const char *TEST_STRING_UNKOWN = "0"; + const char *TEST_STRING_UNKNOWN = "0"; pio_status_t status; enum sex_t sex; @@ -49,9 +49,9 @@ test_parse_sex(void **state) assert_int_equal( status, PIO_OK ); assert_int_equal( sex, PIO_FEMALE ); - sex = parse_sex( TEST_STRING_UNKOWN, strlen( TEST_STRING_UNKOWN ), &status ); + sex = parse_sex( TEST_STRING_UNKNOWN, strlen( TEST_STRING_UNKNOWN ), &status ); assert_int_equal( status, PIO_OK ); - assert_int_equal( sex, PIO_UNKOWN ); + assert_int_equal( sex, PIO_UNKNOWN ); } /**