LoginSignup
2
3

More than 5 years have passed since last update.

pythonでmol2ファイルを分割する (-> 2016.04.17 sdfファイルにも対応)

Last updated at Posted at 2015-10-05

100万エントリー以上の化合物を数個のファイルに分割しなければならなくなったので調べてみた。

最初はopenbabelなどを調べていたのだが、
http://openbabel.org/wiki/--splitinto
を見る限り、openbabel 2.3.0の時点ではこの機能は実装されていないらしく、手元にある2.3.1もダメだった。

ということでコード自作。とりあえず動けばいいや!という魂胆がばれますね!
https://github.com/keisuke-yanagisawa/python-tools/blob/master/split_mol2.py

python split_mol2.py hoge.mol2 #10000化合物ごとに分割がデフォルト
python split_mol2.py -n 100 hoge.mol2 #100化合物ごとに分割

こんな感じに使えます。

-vオプションも用意していて、どんな名前のファイルが出力されているか見ることができるようにしてあります。


2016.04.17
sdfファイルにも対応しました。(実行のやり方とかは変わってない
https://github.com/keisuke-yanagisawa/python-tools/blob/master/split_sdf.py

python split_sdf.py hoge.sdf #10000化合物ごとに分割がデフォルト
python split_sdf.py -n 100 hoge.sdf #100化合物ごとに分割
python split_sdf.py -v hoge.sdf # 何て名前のファイルが出力されたか見れる
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3