title: Usage: align <input file> Error in python
body: <p>Code implements the dynamic programming solution for global pairwise alignment of two sequences. Trying to perform a semi-global alignment between the SARS-CoV-2 reference genome and the first read in the Nanopore sample. The length of the reference genome is 29903 base pairs and the length of the first Nanopore read is 1246 base pairs. When I run the following code, I get this message in my terminal:
  <a href="https://i.stack.imgur.com/5jn2G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5jn2G.png" alt="enter image description here" /></a></p>
  <pre><code>import sys
  import numpy as np
  GAP = -2
  MATCH = 5
  MISMATCH = -3
  MAXLENGTH_A = 29904
  MAXLENGTH_B = 1247
  
  # insert sequence files
  A = open(&quot;SARS-CoV-2 reference genome.txt&quot;, &quot;r&quot;)
  B = open(&quot;Nanopore.txt&quot;, &quot;r&quot;)
  
  def max(A, B, C):
      if (A &gt;= B and A &gt;= C):
          return A
      elif (B &gt;= A and B &gt;= C):
          return B
      else:
          return C
  def Tmax(A, B, C):
      if (A &gt; B and A &gt; C):
          return 'D'
      elif (B &gt; A and B &gt; C):
          return 'L'
      else:
          return 'U'
  def m(p, q):
      if (p == q):
          return MATCH
      else:
          return MISMATCH
  def append(st, c):
      return c + &quot;&quot;.join(i for i in st)
  if __name__ == &quot;__main__&quot;:
      if (len(sys.argv) != 2):
          print(&quot;Usage: align &lt;input file&gt;&quot;)
          sys.exit()
      if (not os.path.isfile(sys.argv[1])):
          print(&quot;input file not found.&quot;)
          sys.exit()
      S = np.empty([MAXLENGTH_A, MAXLENGTH_B], dtype = int)
      T = np.empty([MAXLENGTH_A, MAXLENGTH_B], dtype = str)
      with open(sys.argv[1], &quot;r&quot;) as file:
          A = str(A.readline())[:-1]
          B = str(B.readline())[:-1]
          print(&quot;Sequence A:&quot;,A)
          print(&quot;Sequence B:&quot;,B)
          N = len(A)
          M = len(B)
          S[0][0] = 0
          T[0][0] = 'D'
          for i in range(0, N + 1):
              S[i][0] = GAP * i
              T[i][0] = 'U'
          for i in range(0, M + 1):
              S[0][i] = GAP * i
              T[0][i] = 'L'
          for i in range(1, N + 1):
              for j in range(1, M + 1):
                  S[i][j] = max(S[i-1][j-1]+m(A[i-1],B[j-1]),S[i][j-1]+GAP,S[i-1][j]+GAP)
                  T[i][j] = Tmax(S[i-1][j-1]+m(A[i-1],B[j-1]),S[i][j-1]+GAP,S[i-1][j]+GAP)
          print(&quot;The score of the alignment is :&quot;,S[N][M])
          i, j = N, M
          RA = RB = RM = &quot;&quot;
          while (i != 0 or j != 0):
              if (T[i][j]=='D'):
                  RA = append(RA,A[i-1])
                  RB = append(RB,B[j-1])
                  if (A[i-1] == B[j-1]):
                      RM = append(RM,'|')
                  else:
                      RM = append(RM,'*')
                  i -= 1
                  j -= 1
              elif (T[i][j]=='L'):
                  RA = append(RA,'-')
                  RB = append(RB,B[j-1])
                  RM = append(RM,' ')
                  j -= 1
              elif (T[i][j]=='U'):
                  RA = append(RA,A[i-1])
                  RB = append(RB,'-')
                  RM = append(RM,' ')
                  i -= 1
          print(RA)
          print(RM)
          print(RB)
  </code></pre>