code: def trimNs(seq, line, newagp):
      
      start, end = line.component_beg, line.component_end
      size = end - start + 1
      leftNs, rightNs = 0, 0
      lid, lo = line.component_id, line.orientation
      for s in seq:
          if s in 'nN':
              leftNs += 1
          else:
              break
      for s in seq[::-1]:
          if s in 'nN':
              rightNs += 1
          else:
              break
  
      if lo == '-':
          trimstart = start + rightNs
          trimend = end - leftNs
      else:
          trimstart = start + leftNs
          trimend = end - rightNs
  
      trimrange = (trimstart, trimend)
      oldrange = (start, end)
  
      if trimrange != oldrange:
          logging.debug("{0} trimmed of N's: {1} => {2}".\
                          format(lid, oldrange, trimrange))
  
          if leftNs:
              print("\t".join(str(x) for x in (line.object, 0, 0, 0,
                      'N', leftNs, "fragment", "yes", "")), file=newagp)
          if trimend > trimstart:
              print("\t".join(str(x) for x in (line.object, 0, 0, 0,
                      line.component_type, lid, trimstart, trimend, lo)), file=newagp)
          if rightNs and rightNs != size:
              print("\t".join(str(x) for x in (line.object, 0, 0, 0,
                      'N', rightNs, "fragment", "yes", "")), file=newagp)
      else:
          print(line, file=newagp)
docs: Test if the sequences contain dangling N's on both sides. This component
      needs to be adjusted to the 'actual' sequence range.