get_a3m_size.py 445 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. from a3m import A3M_Container
  3. from a3m import A3MFormatError
  4. import sys
  5. def main():
  6. filename = sys.argv[1]
  7. a3m = A3M_Container()
  8. if(filename.lower() == "stdin"):
  9. fh = sys.stdin
  10. else:
  11. fh = open(filename, "r")
  12. try:
  13. a3m.read_a3m(fh)
  14. size = a3m.get_number_sequences()
  15. print(size)
  16. except A3MFormatError as e:
  17. sys.stderr.write(e)
  18. exit(1)
  19. if __name__ == "__main__":
  20. main()