2017-11-09 9 views
0

多数のサンプルの距離行列を解析しようとしています。入力ファイルは次のようになります。私は、サンプルのリストを持っている最初のラウンド後にPythonループが失敗しますか?

sample 1 sample 2 500 
sample 1 sample 3 109 

は、例えば:にもかかわらず、その後

from sys import argv 
import csv 
script, guuids, infile, distfile, out = argv 
matrix = open(distfile, 'rb') 
matrix_reader=csv.reader(matrix, delimiter='\t') 
guuids_list=[] 
with open(guuids, 'rb') as guuid_file: 
     for line in guuid_file: 
       guuids_list.append(line.strip()) 


with open(infile, 'rb') as guuids: 

     counter=0  
     csv_reader=csv.reader(guuids, delimiter='\t') 


     for line in guuids_list: 
       print guuids_list[counter], guuids_list[counter + 1] 
       for mline in matrix_reader: 


         if guuids_list[counter].strip() ==mline[0] and guuids_list[counter + 1].strip() == mline[1]: 
           print 'no' 
           print line.strip(), guuids_list[counter + 1], mline[2] 
         elif guuids_list[counter + 1].strip() ==mline[0] and guuids_list[counter].strip() == mline[1]: 
           print 'yes' 
           print line.strip(), guuids_list[counter + 1], mline[2] 
       counter += 1 

print guuids_list[1], guuids_list[2] 

これは、最初の二つのサンプルのために働き、何も印刷さ:

sample 1 
sample 2 
sample 3 

私はこれを試してみました次のすべてのサンプルの組み合わせが間違いなく距離行列に表示されているという事実...それを修正する方法はありますか?

答えて

0

私は、Python 3.4でプログラムを実行し、あなたは、私はそれがあなたのpythonモデルのために動作しますので、もしわからない日ほど前にアンインストールpython 2を使用しているがwhile loop問題にfor loopを変更することによって解決されることを見出しました。 試用版

while line in guuids: 
関連する問題