2012年9月11日から15日に掛けての作業メモを整理したものです
FlyBaseにある文献の情報のページ(FBrf*******.html)には、 abstract などように文献には当然ある情報に加え、 その論文で使われた遺伝子、allele、コンストラクト、挿入の情報も、 整理され、掲出されています。
そこで、文献にあるコンストラクトや挿入の情報を取得するための 作業をしたので、記録を残します。 今回は、コンストラクトがどのようなものか、つまり、コンストラクトに 使われた allele がどのようなものかが、業務で必要になり行った作業です。
文献情報 ↓ コンストラクトや挿入情報 ↓ コンストラクトのページから使われた allele 情報を抽出
が基本戦略です。
★ FlyBase の precomputed files では得られない情報。 かといって、FlyBaseの全情報を取得してデータベースを構築するのは 手間が掛かりすぎ。 そこで、htmlファイルとしてデータを取得し、 必要な情報を抽出することにした。 2012年9月22日追記
Files → Current Release からダウンロード
具体的にはココ:http://flybase.org/static_pages/downloads/bulkdata7.html
fbrf_pmid_fb_2012_05.tsv から 「FBrf******」とあるものを取り出し加工
runreference_all.sh: 56526 行
wget http://flybase.org/reports/FBrf0003114.html wget http://flybase.org/reports/FBrf0011208.html wget http://flybase.org/reports/FBrf0012780.html ...
$ cd FBrf $ sh runreference_all.sh
2度止まったので、3階に分けて実行(詳細省略)。
すべてが取得できたわけではないようだ。
56,495 files
sh fileでは、56,526 取得のつもりだった。
$ cd .. $ grep FBti ./FBrf/* > grep_ti.txt $ grep FBtp ./FBrf/* > grep_tp.txt
FBfr と FBti、因子 の対応にエディタを使って編集する(タブ区切り)
grep_ti.txt: 37069 行
FBrf0037054.html | FBti0014771.html | I{}w<sup>IR1</sup> |
FBrf0037612.html | FBti0002823.html | 3S18{}w<sup>a4</sup> |
FBrf0037612.html | FBti0002388.html | copia{}w<sup>a</sup> |
... |
grep_tp.txt: 71224 行
FBrf0038720.html | FBtp0000035.html | P{6.1} |
FBrf0038720.html | FBtp0000036.html | P{ry1} |
FBrf0038720.html | FBtp0000037.html | P{ry3} |
... |
FBti を取得するために、grep_ti.txt を加工し .sh ファイルを作成
FBti*******.html が取得できていないものがあるので、少なくなっている。
runti_temp.sh: 37055行
wget http://flybase.org/reports/FBti0014771.html wget http://flybase.org/reports/FBti0002823.html wget http://flybase.org/reports/FBti0002388.html ...
複数の文献で同一の挿入が扱われることがある
FBtiファイルはひとつ取得すればよい
そこで、重複を除く
shファイルを作る前のFBtiファイル名から重複を除いてももちろん可
(作業手順はほとんど同じ)
unique.pl
#!perl open(IFILE, $ARGV[0]); @myline = <IFILE>; # http://ameblo.jp/debugme/entry-10505621785.html my %hash = map { $_, 1 } @myline; my @unique = keys %hash; print @unique;
$ perl unique.pl runti_temp.sh > runti.sh
runti.sh: 20373 行
wget http://flybase.org/reports/FBti0003892.html wget http://flybase.org/reports/FBti0014868.html wget http://flybase.org/reports/FBti0114075.html ...
$ cp runti.sh ./FBti $ cd FBti $ sh runti.sh
ファイル数: 20373
$ cd .. $ grep FBtp ./FBti/* | grep -v ".png" > grep_ti2tp.txt
FBti と 因子 の対応にエディタを使って編集する
grepが複数拾って来たので、重複を除く
$ perl unique.pl grep_ti2tp.txt > grep_ti2tp_uniq.txt
ソートしてFBtiの順にしておく
grep_ti2tp_uniq.txt: 18869行
FBti0000040.html | FBtp0000078.html | P{hsneo} |
FBti0000046.html | FBtp0000078.html | P{hsneo} |
FBti0000124.html | FBtp0000242.html | P{?2-3} ← デルタが文字化け |
... |
grep_ti2tp_uniq.txt と grep_tp.txt から FBtp*******.html だけを抜き出し、重複を取り除き(上のperlプログラムを使って)、 wget でページを取得するshファイルを作る
runtp.sh: 33605行
wget http://flybase.org/reports/FBtp0000001.html wget http://flybase.org/reports/FBtp0000002.html wget http://flybase.org/reports/FBtp0000003.html ...
$ cp runtp.sh ./FBtp $ cd FBtp $ sh runtp.sh
1度止まったので、2度に分けて実行(詳細省略)
33604 files
「Stocks Listed in FlyBase」とある表示の下の1行下(改行された下の行)に
系統数が記述されている
また、「Stocks」との語はここしかない
そこで、「Stocks」を含む行ともう1行取得し、「Stocks」を含む行を捨てる
$ grep -A 1 Stocks ./FBtp/* | grep -v Stocks | grep -v "\-\-" > tp_num_stocks.txt
33654 行
FBtp と 系統数の対応にエディタを使って編集、念のためソートしておく
tp_num_stocks.txt: 33654 行
FBtp0000001.html | 0 |
FBtp0000002.html | 0 |
FBtp0000003.html | 0 |
... |
FBtp*******.html ファイルの中の記述で、Component Alles の中(下)の
Molecular data の内容を取り出す
因子の説明が書いてあるのはここ
人間が読むにはこれが適切だと思う
ひとつのファイルの中に情報がひとつとは限らないので、取り出した後
まとめる必要がある
Molecular data と書いてある3行下に記述がある
(grep で余分に5行ずつ取って来ている)
その記述は「[空白]<div class="twocol_c_item_one">」に続く
$ grep -A 4 "Molecular data" ./FBtp/* | grep "twocol_c_item_one" > grep_tp_Molecular_data.txt
FBtp と 系統数の対応にエディタを使って編集、念のためソートしておく
grep_tp_Molecular_data.txt: 45544 行
FBtp0000002.html | Construct: 2.1kb SalI-BglII fragment including most of the <a href="/search/simple/symbol/Cp18">Cp18</a> transcription unit. |
FBtp0000002.html | Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function. |
FBtp0000003.html | Construct: Included in 2.7kb genomic BamHI-SalI fragment. |
... |
FBtp*******.html ファイルに2つ以上の Molecular data があるものをまとめる
htmlのタグを残したままので、ふたつ以上つなげるときには、<br>タグを挟むことにした
merge_md.pl
#!perl open(IFILE, $ARGV[0]); $num=0; # 各行をそれぞれ配列に入れる while(<IFILE>){ chop; split /[\t]/; $fbtp[$num] = $_[0]; $moldata[$num] = $_[1]; $num++; } $total = $num; # ひとつ下の行とFBtp*******.htmlが同じならば、ひとつ下のMolecular data # にまとめてしまう # 上側のFBtp*******.html(の情報) は取る(""を代入する) # ひとつのファイルにはMolecular dataはたくさんないので、10個まで見るだ # けにする(スピードアップのため) for($num1=0; $num1<$total; $num1++){ for($num2=($num1+1); $num2<($num1+10); $num2++){ if( !($fbtp[$num1] cmp $fbtp[$num2])){ $moldata[$num2] = $moldata[$num1] . "<br>" . $moldata[$num2]; $fbtp[$num1] = ""; } } } # FBtp*******.html が書いてあるものだけ出力する for($num1=0; $num1<$total; $num1++){ if( $fbtp[$num1] cmp "" ){ print $fbtp[$num1]; print "\t"; print $moldata[$num1]; print "\n"; } }
$ perl merge_md.pl grep_tp_Molecular_data.txt > tp_Molecular_data.txt
tp_Molecular_data.txt: 32485 行
FBtp0000002.html | Construct: 2.1kb SalI-BglII fragment including most of the <a href="/search/simple/symbol/Cp18">Cp18</a> transcription unit.<br>Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function. |
FBtp0000003.html | Construct: 2.7kb BamHI-SalI fragment including <a href="/search/simple/symbol/Cp18">Cp18</a>-<a href="/search/simple/symbol/Cp15">Cp15</a> transcription units.<br>Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function.<br>Construct: Included in 2.7kb genomic BamHI-SalI fragment. |
FBtp0000004.html | Construct: 7.2kb HindIII fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function. |
... |
挿入のデータ(FBti)がreferenceにあったものは、Molecular dataを得るため
に FBtp (コンストラクト)を得たが、コンストラクトのデータがreferenceに
あったものはFbti(挿入)を得ていない
また、名前は、コンストラクトと挿入と両方が参照できるとよい
そこで、grep_ti.txt と grep_ti2tp_uniq.txt から
FBtr[tab]FBtp[tab]Name_tp[tab]FBti[tab]Name_ti
となったファイルを作る
merge_ti_tp.pl
#!perl open(REFTIFILE, "grep_ti.txt"); open(TI2TPFILE, "grep_ti2tp_uniq.txt"); $num=0; # 各行をそれぞれ配列に入れる while(<REFTIFILE>){ chop; split /[\t]/; $fbrf[$num] = $_[0]; $fbti[$num] = $_[1]; $nameti[$num] = $_[2]; $num++; } $total = $num; while(<TI2TPFILE>){ chop; split /[\t]/; $hashti2tp{$_[0]} = ($_[1] . "\t" . $_[2]); } for($num=0; $num<$total; $num++){ print $fbrf[$num]; print "\t"; # FBtp*******.html がないと hash が空白を返すので\tを補う必要がある # そうしないと、桁がずれてしまう if( $hashti2tp{$fbti[$num]} ne ''){ print $hashti2tp{$fbti[$num]}; } else { print "\t"; } print "\t"; print $fbti[$num]; print "\t"; print $nameti[$num]; print "\n"; }
$ perl merge_ti_tp.pl > merged_ti_tp.txt
merged_ti_tp.txt: 37069 行
FBrf0037054.html | FBti0014771.html | I{}w<sup>IR1</sup> | ||
FBrf0037612.html | FBti0002823.html | 3S18{}w<sup>a4</sup> | ||
FBrf0037612.html | FBti0002388.html | copia{}w<sup>a</sup> | ||
...(中略)... | ||||
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001356.html | P{ry1}10DE |
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001357.html | P{ry1}23B |
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001359.html | P{ry1}79E |
... |
grep_tp.txt と merged_ti_tp.txtをひとつのファイルにする
$ cat grep_tp.txt merged_ti_tp.txt > ref_tp_ti.txt
ref_tp_ti.txt: 108293 行
FBrf0038720.html | FBtp0000035.html | P{6.1} | ||
FBrf0038720.html | FBtp0000036.html | P{ry1} | ||
FBrf0038720.html | FBtp0000037.html | P{ry3} | ||
...(中略)... | ||||
FBrf0037054.html | FBti0014771.html | I{}w<sup>IR1</sup> | ||
FBrf0037612.html | FBti0002823.html | 3S18{}w<sup>a4</sup> | ||
FBrf0037612.html | FBti0002388.html | copia{}w<sup>a</sup> | ||
FBrf0037612.html | FBti0002387.html | FB{}w<sup>DZL</sup> | ||
FBrf0037612.html | FBti0002389.html | roo{}w<sup>bf</sup> | ||
FBrf0037612.html | FBti0002390.html | roo{}w<sup>sp1</sup> | ||
FBrf0038659.html | FBti0014154.html | HMS-Beagle{}Lcp3<sup>n1</sup> | ||
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001356.html | P{ry1}10DE |
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001357.html | P{ry1}23B |
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001359.html | P{ry1}79E |
... |
このファイルにストックの数、Molecular data を追加する
merge_all.pl
#!perl open(REFTPTI, "ref_tp_ti.txt"); open(MOLDAT, "tp_Molecular_data.txt"); open(NUMSTOCKS, "tp_num_stocks.txt"); $num=0; # 各行をそれぞれ配列に入れる while(<REFTPTI>){ chop; split /[\t]/; # データがない場合に備え、初期化しておく $fbrf[$num] = ""; $fbtp[$num] = ""; $nametp[$num] = ""; $fbti[$num] = ""; $nameti[$num] = ""; $fbrf[$num] = $_[0]; $fbtp[$num] = $_[1]; $nametp[$num] = $_[2]; $fbti[$num] = $_[3]; $nameti[$num] = $_[4]; $num++; } $total = $num; while(<MOLDAT>){ chop; split /[\t]/; $hashmoldat{$_[0]} = $_[1]; } while(<NUMSTOCKS>){ chop; split /[\t]/; $hashnumstocks{$_[0]} = $_[1]; } # 見出し print "FBrf"; print "\t"; print "FBtp"; print "\t"; print "Name_tp"; print "\t"; print "FBti"; print "\t"; print "Name_ti"; print "\t"; print "Stocks"; print "\t"; print "Molecular_data"; print "\n"; for($num=0; $num<$total; $num++){ print $fbrf[$num]; print "\t"; print $fbtp[$num]; print "\t"; print $nametp[$num]; print "\t"; print $fbti[$num]; print "\t"; print $nameti[$num]; print "\t"; print $hashnumstocks{$fbtp[$num]}; print "\t"; print $hashmoldat{$fbtp[$num]}; print "\n"; }
$ perl merge_all.pl > ref_tp_ti_st_md.txt
ref_tp_ti_st_md.txt: 108293 行(見出し含む)
FBrf | FBtp | Name_tp | FBti | Name_ti | Stocks | Molecular_data |
FBrf0038720.html | FBtp0000035.html | P{6.1} | 0 | |||
FBrf0038720.html | FBtp0000036.html | P{ry1} | 1 | Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function.<br>Included within an 8.2kb genomic SalI fragment. | ||
FBrf0038720.html | FBtp0000037.html | P{ry3} | 0 | Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function.<br>Included within an 8.2kb genomic SalI fragment. | ||
FBrf0038720.html | FBtp0000167.html | P{S11.4} | 0 | Construct: 3.8kb SalI genomic fragment containing the <a href="/search/simple/symbol/Cp15">Cp15</a> and <a href="/search/simple/symbol/Cp18">Cp18</a> transcripts.<br>Construct: 3.8kb SalI genomic fragment containing the <a href="/search/simple/symbol/Cp15">Cp15</a> and <a href="/search/simple/symbol/Cp18">Cp18</a> transcripts. | ||
FBrf0038720.html | FBtp0000168.html | P{?25.1} | 0 | Fragment containing a complete 2.9kb <a href="/search/simple/symbol/P-element">P-element</a>. | ||
FBrf0038720.html | FBtp0000166.html | P{?25.7} | 0 | Fragment containing a complete 2.9kb <a href="/search/simple/symbol/P-element">P-element</a>. | ||
FBrf0038996.html | FBtp0000169.html | P{?12.20} | 0 | Construct: 2.9kb fragment encompassing full length <a href="/search/simple/symbol/P-element">P-element</a>. | ||
FBrf0038996.html | FBtp0000168.html | P{?25.1} | 0 | Fragment containing a complete 2.9kb <a href="/search/simple/symbol/P-element">P-element</a>. | ||
FBrf0038998.html | FBtp0000217.html | P{Ddc1/4} | ||||
... |
(「?」はShift-JISでは文字化けするのでここでは書き替えた)
$ sort ref_tp_ti_st_md.txt > ref_tp_ti_st_md_sorted.txt
ref_tp_ti_st_md_sorted.txt: 108293 行(見出し含む)
FBrf | FBtp | Name_tp | FBti | Name_ti | Stocks | Molecular_data |
FBrf0037054.html | FBti0014771.html | I{}w<sup>IR1</sup> | ||||
FBrf0037612.html | FBti0002387.html | FB{}w<sup>DZL</sup> | ||||
FBrf0037612.html | FBti0002388.html | copia{}w<sup>a</sup> | ||||
FBrf0037612.html | FBti0002389.html | roo{}w<sup>bf</sup> | ||||
FBrf0037612.html | FBti0002390.html | roo{}w<sup>sp1</sup> | ||||
FBrf0037612.html | FBti0002823.html | 3S18{}w<sup>a4</sup> | ||||
FBrf0038659.html | FBti0014154.html | HMS-Beagle{}Lcp3<sup>n1</sup> | ||||
FBrf0038720.html | FBtp0000035.html | P{6.1} | 0 | |||
FBrf0038720.html | FBtp0000036.html | P{ry1} | 1 | Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function.<br>Included within an 8.2kb genomic SalI fragment. | ||
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0000963.html | P{ry1}R404.2 | 1 | Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function.<br>Included within an 8.2kb genomic SalI fragment. |
FBrf0038720.html | FBtp0000036.html | P{ry1} | FBti0001356.html | P{ry1}10DE | 1 | Construct: 8.1kb SalI fragment that contains <a href="/search/simple/symbol/ry">ry</a><sup>+</sup> function.<br>Included within an 8.2kb genomic SalI fragment. |
... |
一応の完成だが、ファイルが大きくて見づらい…… エクセル2007ならそのまま扱えるので、まいっか
Today:1 | Yesterday:1 | Total:3829 since 16 September 2012 |