kuroの覚え書き

96の個人的覚え書き

ペプチドをコードするDNAを網羅的に探す。

例えばCLE25ペプチドはArg-Lys-Val-Pro-Asn-Gly-Pro-Asp-Ile-His-Asnからなるが(実際は246bpの前駆体がまず転写され翻訳されるのだが)、このペプチドがどんなゲノムDNA配列から転写翻訳されたかを考えたい。
Arg:CGT/CGC/CGA/CGG/AGA/AGG
Lys:AAA/AAG
Val:GTT/GTC/GTA/GTG
Pro:CCT/CCC/CCA/CCG
Asn:AAT/AAC
Gly:GGT/GGC/GGA/GGG
Pro:CCT/CCC/CCA/CCG
Asp:GAT/GAC
Ile:ATT/ATC/ATA
His:CAT/CAC
Asn:AAT/AAC
これらの組み合わせなので、6x2x4x4x2x4x4x2x3x2x2=147456通りのDNA配列から転写翻訳される可能性がある。
これをすべて人力で羅列することは不可能なので、計算機の出番。本当はシェル芸でできるといいのだけれど、ひとまずExcelVBAでごまかす。

VBAを開き、

Sub AA01()
a = Cells(Rows.Count, "A").End(xlUp).Row 
b = Cells(Rows.Count, "B").End(xlUp).Row 
For i = 1 To a 
For n = 1 To b 
x = x + 1
Cells(x, "C") = Cells(i, "A") & " " & Cells(n, "B")
Next n
Next i
End Sub

と入力
そして列A,Bに1番目のアミノ酸のコドンを並べ、Bに2番目のアミノ酸のコドンを並べる。
で、ツール>マクロ>マクロ...とたどるとSheet1.AA01というマクロが選択されているのでそのまま「実行」
f:id:k-kuro:20220117163218p:plain
こんな感じにスペースが挟まるが総当りでつなげてくれる。
これを最後のアミノ酸まで順番に継ぎ足していくと、147456通りのDNA配列が出来上がる。
それぞれのDNAに>cle25-1, >cle25-2...のように名前列を先頭につけて一旦cle25.tsvで保存する。

$ cat cle25.tsv | tr -d ' ' | tr '\t' '\n' > cle25.fasta

というようにfasta形式にしてやる。
あとはゲノム上のどこにあるかはBlastnで探す。

$ blastn -query cle25.fasta -db TAIR10genome -word_size 33 -outfmt 7 -num_threads 4 | awk '/hits found/{getline;print}' | grep -v "#" > blast_cle25.txt

これで100%マッチする配列が出てくるはず。

Dockerのコンテナをイメージに書き出して別のJetson Nanoに環境を移す

ここまでJetson Nano 2GBでDocker上にPython3環境を作ってきたが、32GBのSDカードだったためちょいと手狭になってきた。
JetsonNano B01のほうは128GBだったので一旦こっちに環境を移して続きの開発を行いたい。

ということでDocker-composeで構築したコンテナを一旦イメージに書き出そうと思う。

まずは一旦コンテナを終了する。

$ docker ps -a
CONTAINER ID   IMAGE            COMMAND     CREATED      STATUS         PORTS                                       NAMES
378becd47c1a   python_python3   "python3"   8 days ago   Up 4 minutes   0.0.0.0:5001->5001/tcp, :::5001->5001/tcp   python3

$ docker stop python3

$ docker ps -a
CONTAINER ID   IMAGE            COMMAND     CREATED      STATUS         PORTS                                       NAMES
378becd47c1a   python_python3   "python3"   8 days ago   Exited (0) 4 seconds ago   0.0.0.0:5001->5001/tcp, :::5001->5001/tcp   python3

次にコンテナをイメージに書き出す。python3のイメージをもとにしたコンテナでFlaskによるウェブアプリを構築した状態なので

$ docker commit python3 python3_flask

というふうにした。
さらにこのイメージをファイルとして取り出すため

$ docker save -o /mnt/mac/python3_flask.tar python3_flask

とした。/mnt/macはJetsonNano2GBにマウントしたMacのホームディレクトリ。

さて、一方のJetsonNanoB01の方でもDocker-composeが使えるようにした上で、さっき作った/mnt/mac/python3_flask.tarをDockerの実行ディレクトリに置く。

$ nano Dockerfile

FROM python3_flask:latest
USER root

RUN apt update
RUN apt -y install locales && \
    localedef -f UTF-8 -i ja_JP ja_JP.UTF-8
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8
ENV TZ JST-9
ENV TERM xterm

$ nano docker-compose.yml 

version: '3'
services:
  python3:
    restart: always
    build: .
    container_name: 'python3'
    working_dir: '/root/'
    tty: true
    volumes:
      - ./opt:/mnt/opt
    ports:
      - "5001:5001"

とファイルを作っておく。docker-compose.ymlは2GBで作ったものと特に変更はなく、Dockerfileの1行目のFROMの部分を自分が作ったイメージにしておく。
で、

$ docker-compose up -d --build

としてやると、自分で作ったイメージからコンテナを構築してくれる。

$ docker ps -a
CONTAINER ID   IMAGE            COMMAND     CREATED       STATUS         PORTS                                       NAMES
46b72084b844   python_python3   "python3"   2 hours ago   Up 9 minutes   0.0.0.0:5001->5001/tcp, :::5001->5001/tcp   python3

これで移植完了。特に問題なくpythonもその他インストールしたblastやclustalwプログラムも動くことを確認した。

っしかしわかっていたことだが、やっぱりJetsonNanoのARM A57 cpu @ 1.43 GHzではblastを実用的に走らせるのはきつそうだ。tblastxとか考え込んでちっとも結果が帰ってこない。SDカードの読み込み速度がそんなに速くないからか?ベンチマーク的にはHaswelなXeonより劣るくらいという話だったが、クロックが低いし4コアだからか?

JetsonNanoにMacのディレクトリをマウントする

JetsonNanoとMacはネットワークではなくUSBで直結しているものとする。

Mac側の準備
OSはCatalina
ユーザーkuroのホームディレクトリをマウントしたい。

% sudo nano /etc/exports

/System/Volumes/Data/Users/kuro -maproot=root -network 192.168.55.0 -mask 255.255.255.0

% sudo launchctl start com.apple.nfsd 
% sudo nfsd update

 % showmount -e localhost        
Exports list on localhost:
/System/Volumes/Data/Users/kuro    192.168.55.0

JetsonNano
/mnt/macにマウントする。

$ sudo mkdir /mnt/mac
$ sudo chmod 777 /mnt/mac
$ sudo mount 192.168.55.100:/System/Volumes/Data/Users/kuro  /mnt/mac

Docker-composeでpython3環境をJetson Nanoに作る。

Jetson NanoにDocker-composeを入れるところまではやったので、その先の実際の運用例としてpython環境を構築してみる。

Jetson Nanoにも素の状態のpython3はインストールされているのだが、この素のpython環境にごちゃごちゃライブラリをインストールしようとすると案外うまく入ってくれない。Jetsonに固有の事情があるようだ。なのでdockerコンテナとしてpythonやそれを使ったWebアプリの環境をまとめて構築しておこうと思う。

まずはディレクトリを作り、いくつかファイルを準備。

mkdir -p ~/docker/python
cd ~/docker/python
touch Dockerfile
touch docker-compose.yml

Dockerfileの内容は

FROM python:3
USER root

RUN apt update
RUN apt -y install locales && \
    localedef -f UTF-8 -i ja_JP ja_JP.UTF-8
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8
ENV TZ JST-9
ENV TERM xterm

RUN apt install -y nano less

たとえばこんな感じ。
1行目:FROM python3
でDockerが公式に用意しているpythonのコンテナイメージをダウンロードしてきて読み込むようだ。
2行目:コンテナの中でユーザはrootとして振る舞う。これを一般ユーザにすることはできるのか?>要調査
基本的にこのコンテナはデフォルトではlinux/debianの上に構築されるらしい。故にコンテナを作ったあとには一通りのアップデートやロケールなど環境設定を自動でやっておくコマンドが続く。
最後の行でnanoとlessコマンドをインストールしている。
debianなのでaptだ。個人的にはcentosyumのほうがなれているんだけどな。

次にdocker-compose.ymlの中身を見てみよう。

version: '3'
services:
  python3:
    restart: always
    build: .
    container_name: 'python3'
    working_dir: '/root/'
    tty: true
    volumes:
      - ./opt:/root/opt

versionはdocker-compose.ymlのバージョンで、最新は3。2で書いているのものまだまだ見られるが、バージョンごとに書式が変わっている点があるらしい。>要調査
serviceというのがdocker-composeで複数のコンテナを連携させるときのそれぞれのコンテナを表していると考えて良さそうだ。
ここではpython3というサービスを定義している。
restart:実行時に再起動するか。
build:buildするときのディレクト
working_dir:コンテナに入ったときに入るディレクト
volumes:のところで - ./opt:/root/opt となっているのは現在のディレクトリ(Dockerfileやdocker−compose.ymlをおいたところ)に作成したoptというディレクトリをコンテナ内で/root/optにマウントしますよという意味になっている。
そのほか
ports:ポートをどうつなげるか
depends_on:Service同士の依存関係。ここで指定したサービスを先に起動する。
など。詳細はまだ調査がいるな。


さて、ここまで準備ができたら

$ docker-compose up -d --build
Creating network "python_default" with the default driver
Building python3
Sending build context to Docker daemon  5.632kB
Step 1/13 : FROM python:3
3: Pulling from library/python
6476cb406b24: Pull complete 
96565d527970: Pull complete 
aa8c15f93136: Pull complete 
ee42e24e52cb: Pull complete 
3ac9532df0bb: Pull complete 
3685c02ef2f5: Pull complete 
a9b3e03b8516: Pull complete 
22051255765a: Pull complete 
ebe16c245b5a: Pull complete 
Digest: sha256:7537c2092cdd042405001f8534b417bb276fa44303b7d1736769941907f2a19e
Status: Downloaded newer image for python:3
 ---> 9d506afcb923
Step 2/13 : USER root
 ---> Running in f59d011d672f
Removing intermediate container f59d011d672f
 ---> 7df717859527
Step 3/13 : RUN apt-get update
 ---> Running in 6c39af17c5cb

・・・・・・

Removing intermediate container 3000d9db4298
 ---> d6f5b13966d0
Successfully built d6f5b13966d0
Successfully tagged python_python3:latest
Creating python3 ... done

こんな感じで無事コンテナが出来上がる。
早速出来上がったpython3環境に入ってみる。

$ docker-compose exec python3 bash
root@00140c230b15:~# 

無事入れた。
これでJetsonの素の環境に依存しないpython(およびdebian)が使えるということだ。

何も設定せずデフォルトのまま構築してみたところ、pythonのバージョンは3.10が入った。しかしどうもこのバージョンはこれまでに作ったFlaskアプリと相性が悪いみたいなので、一旦downしてDockerfileを編集。

FROM Python:3.9.9

ついでにdocker-compose.ymlのポートも

ports:
- "5000:5000"

こうしておくとホストに5000でアクセスしたら自動的にDockerの5000にリダイレクトされるようになる。

Docker-composeをJetson Nanoで使う。

Docker-composeをJetson nanoに入れてdockerの起動を楽にする試み。

まずはDocker-composeをインストールする。

sudo apt install python3-pip
sudo apt install build-essential libssl-dev libffi-dev python3-dev
sudo pip3 install docker-compose
-----------
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-pzvne0ph/cryptography/setup.py", line 14, in <module>
        from setuptools_rust import RustExtension
    ModuleNotFoundError: No module named 'setuptools_rust'
    
            =============================DEBUG ASSISTANCE==========================
            If you are seeing an error here please try the following to
            successfully install cryptography:
    
            Upgrade to the latest pip and try again. This will fix errors for most
            users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
            =============================DEBUG ASSISTANCE==========================
    
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-pzvne0ph/cryptography/

そうするとsetuptools_rustが入ってないよ的なエラーが出たので、

sudo pip3 install setuptools_rust
sudo pip3 install docker-compose

とりあえずテストをしてみる。
まず、dockerがちゃんと動くか

docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
93288797bd35: Pull complete 
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

OK

次にdocker-composeで起動してみる。
まず、適当なディレクトリを作り、中にdocker-compose.ymlというファイルを作る。

$ mkdir docker_test
$ cd docker_test
$ nano docker-compose.yml

$ cat docker-compose.yml
version: "2"

services:
  app:
    image: hello-world

で、

$ docker-compose up
Creating network "docker_test_default" with the default driver
Creating docker_test_app_1 ... done
Attaching to docker_test_app_1
app_1  | 
app_1  | Hello from Docker!
app_1  | This message shows that your installation appears to be working correctly.
app_1  | 
app_1  | To generate this message, Docker took the following steps:
app_1  |  1. The Docker client contacted the Docker daemon.
app_1  |  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
app_1  |     (arm64v8)
app_1  |  3. The Docker daemon created a new container from that image which runs the
app_1  |     executable that produces the output you are currently reading.
app_1  |  4. The Docker daemon streamed that output to the Docker client, which sent it
app_1  |     to your terminal.
app_1  | 
app_1  | To try something more ambitious, you can run an Ubuntu container with:
app_1  |  $ docker run -it ubuntu bash
app_1  | 
app_1  | Share images, automate workflows, and more with a free Docker ID:
app_1  |  https://hub.docker.com/
app_1  | 
app_1  | For more examples and ideas, visit:
app_1  |  https://docs.docker.com/get-started/
app_1  | 
docker_test_app_1 exited with code 0

$ docker-compose images
    Container       Repository     Tag       Image Id       Size  
------------------------------------------------------------------
docker_test_app_1   hello-world   latest   18e5af790473   9.136 kB

$ docker-compose ps
      Name          Command   State    Ports
--------------------------------------------
docker_test_app_1   /hello    Exit 0        

$ docker container ls -a
CONTAINER ID   IMAGE         COMMAND    CREATED              STATUS                      PORTS     NAMES
5c4c5e2b5718   hello-world   "/hello"   About a minute ago   Exited (0) 53 seconds ago             docker_test_app_1

docker-composeのオプションとしては

$ docker-compose -h
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [--profile <name>...] [options] [--] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file
                              (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name
                              (default: directory name)
  --profile NAME              Specify a profile to enable
  -c, --context NAME          Specify a context name
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --ansi (never|always|auto)  Control when to print ANSI control characters
  --no-ansi                   Do not print ANSI control characters (DEPRECATED)
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the
                              name specified in the client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert keys
                              in v3 files to their non-Swarm equivalent (DEPRECATED)
  --env-file PATH             Specify an alternate environment file

Commands:
  build              Build or rebuild services
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove resources
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show version information and quit

となっている。
docker-compose up
を実行するとカレントディレクトリのDockerfile、docker-compose.ymlに従ってコンテナを作り、サービスを開始する。
逆に
docker-compose down
を実行するとサービスを停止し、コンテナを破棄する。

$ docker-compose down
Removing test_app_1 ... done
Removing network test_default

docker-compose stop
だとサービスの停止だけでコンテナは残るので
docker-compose start
でサービスをスタートする。

またdownでコンテナを破棄してもイメージは残っている。

$ docker image ls
REPOSITORY              TAG           IMAGE ID       CREATED         SIZE
hello-world             latest        18e5af790473   2 months ago    9.14kB

必要がなければ
docker image rm 18e
のようにイメージも削除

次はDockerfileとdocker-compose.ymlの中身について解きほぐす。

Rspberry piにnumpy

Raspberry piにpipでnumpyを入れようとしたら動かなかった。これまたARMに対応してないらしいね。

対応策としては

$ sudo apt install python3-numpy

と直接インストールするといいらしい。
一旦

$ python3 -m pip uninstall numpy

としてやってからインストールする。
その後matplotlibをインストールしようとしたところ、numpyを要求し、勝手にpipでnumpyをアップデートしやがった。
振り出しに戻る。
ここでまたnumpyをアンインストールしてaptで入れ直したところ、matplotlibの配下にnumpy絡みのライブラリがないというようなエラーが出た。なのでpipでアンインストールはせずに、aptでreinstallで上書きをしてやると、クリア。
しかしまたなにやらエラーが出てとまる。libf77blas.so.3がないとな。

$ sudo apt install libatlas-base-dev

これで解決。

Raspberry piにBlastとSamtoolsをインストール

XREAがいまいち融通がきかない。ちょっと規模の大きいFlaskサイトを動かそうとすると負荷がかかりすぎるのか強制終了されてしまい、サーバエラーを返されてしまう。
一旦XREAペンディングとし、自宅ネットにRaspberry piでwebアプリ設置テストをすることに方針変更。

python3環境はとりあえずできているが、bioinfo系のアプリが入っていないのでそのあたりの環境構築から実施することにする。
Raspberry piはARMなのでbrewが使えないのでやはり個別インストールするしかない。
(Apple M1には対応しているんだからLinuxbrewも対応してくれても良さそうなもんだが)

まずsamtools
www.htslib.org
ここからソースをダウンロード

$ wget https://github.com/samtools/samtools/releases/download/1.14/samtools-1.14.tar.bz2
$ tar -xf samtools-1.14.tar.bz2
$ cd samtools-1.14
$ ./configure --prefix=$HOME

そうするとエラー

configure: error: curses development files not found

なので

$ sudo apt-get install libcurses-*

気を取り直して

$ ./configure --prefix=$HOME
configure: error: libbzip2 development files not found

まだだ、

$ sudo apt-get install libbz2-dev

$ ./configure --prefix=$HOME
configure: error: liblzma development files not found

うーむ

$ sudo apt-get install liblzma-dev

これでようやくconfigureができた。あとは

$ make
$ make install

これでOK適当にパスの通ったところにsamtoolsをコピーしておく。

つぎにBlast
ftp.ncbi.nlm.nih.gov
ここからダウンロードするのだがlinuxのバイナリ
https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.12.0+-x64-linux.tar.gz
intel用なのでraspberry piでは動かず。
なのでやはりソースからbuild

$ wget https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.12.0+-src.tar.gz
$ tar -xvzf ncbi-blast-2.12.0+-src.tar.gz
$ cd ncbi-blast-2.12.0+-src/c++
$ ./configure --prefix=$HOME
$ make
$ make install

XREAサーバを使う(3)nano編

brewを入れるのは容量的にも得策ではないな、ということで必要なアプリケーションは個別にbuildしてインストールすることにする。
手始めに、nanoエディタを入れてみる。標準ではviは使えるけれど、nanoは入ってなかったので。viでいいじゃないかという意見もあろうがnanoのほうがちょっとした編集にはお手軽なもんで。

まずはソースを取ってくる。

$ wget https://www.nano-editor.org/dist/v5/nano-5.9.tar.gz
$ tar -xvzf nano-5.9.tar.gz
$ rm nano-5.9.tar.gz
$ cd nano-5.9

インストール

$ ./configure --prefix=$HOME --enable-color --enable-multibuffer --enable-nanorc --enable-utf8
$ make
$ make install
$ nano
  GNU nano 5.9                     新しいバッファ                               








             [ nano へようこそ。 Ctrl+G で簡単なヘルプが出ます。 ]
^G ヘルプ    ^O 書き込み  ^W 検索      ^K 切り取り  ^T コマンドを^C 位置
^X 終了      ^R 読み込み  ^\ 置換      ^U 貼り付け  ^J 均等割付  ^/ 行を指定

よしよし。

doc/sample.nanorcを~に.nanorcとしてコピーして置いとくと色々設定ができるらしいな。

XREAサーバを使う(2) Flask編

Homebrewのインストールは未完。Gitはインストールできたがcurlなど他にも対応しなければならないし、そもそもそこまでいろんなアプリを入れたいわけでもない。せいぜいblastとsamtoolsくらいなので、個別インストールしたほうが早そうなので、一旦ペンディング

とにかくFlaskでウェブアプリを走らせたい。

以前Value serverではできていたはずだが、どうやっていたかすっかりさっぱり忘れていて全然うまく走らない。
まずはXREA個別の事情もあるかもしれないのでstep by stepでクリアしていこう。

最初に確認しておくこととしてはどうやら.htaccessがHTMLルート(root /public_html)でしか働かないかもしれないとのこと。
またここにインデックスファイルを置いておく必要があり、それは.pyではまずいらしいこと。なのでファイル名はindex.cgiとしておくことにする。

.htaccess

#AddHandler cgi-script .py
#DirectoryIndex index.cgi
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.cgi/$1 [QSA,L]
<Files ~ "\.py$">
    deny from all
</Files>

index.cgi

#!/usr/local/bin/python3
# coding: utf-8

import cgitb
cgitb.enable()

from wsgiref.handlers import CGIHandler

from main import app
import os
os.environ["REQUEST_METHOD"] = "GET"

CGIHandler().run(app)

main.py

#!/usr/local/bin/python3
# -*- coding: utf-8 -*-

from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
    return "Hello world!"
if __name__ == '__main__':
    app.run()

このような感じでファイルを作成し、
.htaccess 644
index.cgi 700
main.py 700
のようにアクセス権を設定して

ブラウザでアクセスすると

Hello world!"

が無事に表示された。


最初index.cgi

import os
os.environ["REQUEST_METHOD"] = "GET"

この部分をなしにしていると
500 internal error
がでてぜんぜん動かなかったのだが、試しに

$ python3 index.cgi

と直接起動してみたら

KeyError: 'REQUEST_METHOD'
Status: 500 Internal Server Error
Content-Type: text/plain
Content-Length: 59

のようなエラーが出ていることがわかったので
KeyError: 'REQUEST_METHOD'
で検索して、
coffee-blue-mountain.com
こちらのサイトを参考にして対応した。

これがわかるまでに半日費やした。

XREAサーバを使う

以前GMOvalue serverを利用してデータベースサイトの試験運用を行っていた。

今回久しぶりに同系列で完全無料で利用できる(広告は入る)XREAレンタルサーバを使ってサイト構築をしてみようと思う。
無料で使えるのは1GBまでなので大規模なデータベースは無理だが、とりあえずのドラフトテストくらいならできるだろう。

さて、XREAで何ができそうか。
まずpython3はインストールされているしpython3 -m pip installもすんなり動いた。
ところが標準状態ではrbashになっているらしくcdすら制限されている。
なのでまずは

$ chsh
kuro のシェルを変更します。
新しいシェル [/bin/rbash]: /bin/bash
パスワード:
シェルを変更しました。

とシェルをbashに変更しておく。
一旦ログアウトして再度sshでログインするとbashが動いている。
次にせっかくだからbrewも入れてやろうと例のスクリプト

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
The version of Git that was found does not satisfy requirements for Homebrew.
Please install Git 2.7.0 or newer and add it to your PATH.

むう。おまえもか。

ということでgitのインストールを次に頑張ってみる。

$ mkdir local
$ cd local
$ mkdir src
$ mkdir bin
$ cd src
$ wget https://www.kernel.org/pub/software/scm/git/git-2.7.0.tar.gz
$ tar xvzf git-2.7.0.tar.gz
$ cd git-2.7.0
$ ./configure --prefix=$HOME/local
$ gmake
$ gmake test
$ gmake install
$ cd contrib/completion/
$ cp git-completion.bash ~/local/bin/

bashにPATHを通しておく
~/.bashrc

# Path Setting
export PATH=$PATH:/virtual/kuro/local/bin
#Complete Setting
if [ -e "$HOME/local/bin/git-completion.bash" ]; then
    source "$HOME/local/bin/git-completion.bash"
fi

続く