| |
python:biopython [2017/11/24 11:05] – 作成 mumeiyamibito | python:biopython [2019/10/04 10:14] (現在) – [配列ファイル (Genbank, Fasta) の取得&保存] mumeiyamibito |
---|
<code python> | <code python> |
obj_gb = Entrez.efetch(db = "データベース名", id = 配列ID, rettype = "gb", retmode = "text") | obj_gb = Entrez.efetch(db = "データベース名", id = 配列ID, rettype = "gb", retmode = "text") |
obj_output = open(args.output_file, "w") | obj_output = open(OUTPUT_PATH, "w") |
obj_output.write(obj_gb.read()) | obj_output.write(obj_gb.read()) |
</code> | </code> |
* ''efetch()'' メソッドでデータの実体を取得する。 | * ''efetch()'' メソッドでデータの実体を取得する。 |
* ''配列ID'' は ''esearch()'' の結果の `IdList` キーにリスト形式で格納されているのでそれを指定する。 | * ''配列ID'' は ''esearch()'' の結果の `IdList` キーにリスト形式で格納されているのでそれを指定する。 |
| * ''OUTPUT_PATH'' は出力先のファイルパス |
* ''rettype'' と ''retmode'' で出力するファイルタイプを指定する。詳しくは [[https://www.ncbi.nlm.nih.gov/books/NBK25499/table/chapter4.T._valid_values_of__retmode_and/?report=objectonly | Table 1, \[– Valid values of &retmode and &rettype for EFetch (null = empty string)\]. - Entrez Programming Utilities Help - NCBI Bookshelf]] を参照。 | * ''rettype'' と ''retmode'' で出力するファイルタイプを指定する。詳しくは [[https://www.ncbi.nlm.nih.gov/books/NBK25499/table/chapter4.T._valid_values_of__retmode_and/?report=objectonly | Table 1, \[– Valid values of &retmode and &rettype for EFetch (null = empty string)\]. - Entrez Programming Utilities Help - NCBI Bookshelf]] を参照。 |
* 今回は、GenBank 形式で出力するため、''rettype = "gb", retmode = "text"'' とした。 | * 今回は、GenBank 形式で出力するため、''rettype = "gb", retmode = "text"'' とした。 |