title: Python 'Tuple' object has no attribute 'has_key'
body: <p>I'm running a piece of freely available python code used to detect CNVs in single cell sequencing data: </p>
  
  <pre><code>#!/usr/bin/env python
  
  import sys
  
  def main():
  
      infilename = sys.argv[1]
      outfilename = sys.argv[2]
      statfilename = sys.argv[3]
  
      chrominfo = ("/path/hg19.chrom.sizes.txt", 0)
      bins = ("/path/hg19.bin.boundaries.50k.bowtie.k50.sorted.txt", 0)
      INFILE = open(infilename, "r")
      OUTFILE = open(outfilename, "w")
      STATFILE = open(statfilename, "w")
  
      binCounts = []
      for i in range(len(bins)):
          binCounts.append(0)
  
      print len(binCounts)
      print len(bins)
  
      counter = 0
      totalReads = 0
      prevChrompos = ""
      for x in INFILE:
          arow = x.rstrip().split("\t")
          thisChrom = arow[2]
          thisChrompos = arow[3]
          if thisChrom.find("_") &gt; -1:
              #print thisChrom
              continue
          if thisChrom == "chrM":
              #print thisChrom
              continue
          if thisChrom == "":
              continue
          if chrominfo.has_key(thisChrom):
              pass
          else:
              continue
  
          totalReads += 1
  
          thisChrominfo = chrominfo[thisChrom]
          thisAbspos = long(thisChrompos) + long(thisChrominfo[2])
  
          counter += 1
  
          indexUp = len(bins) - 1
          indexDown = 0
          indexMid = int((indexUp - indexDown) / 2.0)
  
          while True:
              if thisAbspos &gt;= long(bins[indexMid][2]):
                  indexDown = indexMid + 0
                  indexMid = int((indexUp - indexDown) / 2.0) + indexMid
              else:
                  indexUp = indexMid + 0
                  indexMid = int((indexUp - indexDown) / 2.0) + indexDown
  
              if indexUp - indexDown &lt; 2:
                  break
  
          binCounts[indexDown] += 1
          prevChrompos = thisChrompos
  
      for i in range(len(binCounts)):
          thisRatio = float(binCounts[i]) / (float(counter) / float(len(bins)))
          OUTFILE.write("\t".join(bins[i][0:3]))
          OUTFILE.write("\t")
          OUTFILE.write(str(binCounts[i]))
          OUTFILE.write("\t")
          OUTFILE.write(str(thisRatio))
          OUTFILE.write("\n")
  
      binCounts.sort()
  
      STATFILE.write("TotalReads\tMedianBinCount\n")
      STATFILE.write(str(totalReads))
      STATFILE.write("\t")
      STATFILE.write(str(binCounts[len(bins)/2]))
      STATFILE.write("\n")
  
      INFILE.close()
      OUTFILE.close()
      STATFILE.close()
  
  
  def fileToDictionary(inputFile, indexColumn):
      input = open(inputFile, "r")
  
      rd = dict()
  #   input.readline()
      for x in input:
          arow = x.rstrip().split("\t")
          id = arow[indexColumn]
          if rd.has_key(id):
              #rd[id].append(arow)
              print "duplicate knowngene id = " + id
              print "arow =   " + str(arow)
              print "rd[id] = " + str(rd[id])
          else:
              rd[id] = arow
  
      input.close()
      return(rd)
  
  
  def fileToArray(inputFile, skipFirst):
      input = open(inputFile, "r")
  
      ra = []
  
      for i in range(skipFirst):
          input.readline()
  
      for x in input:
          arow = x.rstrip().split("\t")
          ra.append(arow)
  
      input.close()
      return(ra)
  
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>I'm getting an error on line 40:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/path/varbin.50k.sam.py", line 129, in &lt;module&gt;
      main()
    File "/path/varbin.50k.sam.py", line 40, in main
      **if chrominfo.has_key(thisChrom):
  AttributeError: 'tuple' object has no attribute 'has_key'**
  </code></pre>
  
  <p>I don't work regularly in Python, can someone offer a suggestion? 
  Where do I begin? </p>