subprocess モジュールを使用して UNIX ソートを呼び出す Python スクリプトを作成しました。2 つの列 (2 と 6) に基づいてテーブルを並べ替えようとしています。これが私がやったことです
sort_bt=open("sort_blast.txt",'w+')
sort_file_cmd="sort -k2,2 -k6,6n {0}".format(tab.name)
subprocess.call(sort_file_cmd,stdout=sort_bt,shell=True)
ただし、出力ファイルには不完全な行が含まれており、テーブルを解析するとエラーが発生しますが、行をソートするために指定された入力ファイルのエントリをチェックすると、完全に見えます。sort が指定されたファイルに結果を書き込もうとするときに問題があると思いますが、解決方法はわかりません。
入力ファイルの行は次のようになります
gi|191252805|ref|NM_001128633.1| Homo sapiens RIMS 結合タンパク質 3C (RIMBP3C)、mRNA gnl|BL_ORD_ID|4614 gi|124487059|ref|NP_001074857.1| RIMS 結合タンパク質 2 [Mus musculus] 103 2877 3176 846 941 1.0102e-07 138.0
ただし、出力ファイルには gi|19125 のみが出力されます。これを解決するにはどうすればよいですか?
どんな助けでも大歓迎です。
RAM