PageRenderTime 50ms CodeModel.GetById 45ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/next_gen_conversion/fastq_conversions.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 41 lines | 21 code | 6 blank | 14 comment | 6 complexity | 397cda9efdb019545c1686ab9bc4730f MD5 | raw file
  1. #!/usr/bin/env python
  2. """
  3. Performs various conversions around Sanger FASTQ data
  4. usage: %prog [options]
  5. -c, --command=c: Command to run
  6. -i, --input=i: Input file to be converted
  7. -o, --outputFastqsanger=o: FASTQ Sanger converted output file for sol2std
  8. -s, --outputFastqsolexa=s: FASTQ Solexa converted output file
  9. -f, --outputFasta=f: FASTA converted output file
  10. usage: %prog command input_file output_file
  11. """
  12. import os, sys, tempfile
  13. from galaxy import eggs
  14. import pkg_resources; pkg_resources.require( "bx-python" )
  15. from bx.cookbook import doc_optparse
  16. def stop_err( msg ):
  17. sys.stderr.write( "%s\n" % msg )
  18. sys.exit()
  19. def __main__():
  20. #Parse Command Line
  21. options, args = doc_optparse.parse( __doc__ )
  22. cmd = "fq_all2std.pl %s %s > %s"
  23. if options.command == 'sol2std':
  24. cmd = cmd % (options.command, options.input, options.outputFastqsanger)
  25. elif options.command == 'std2sol':
  26. cmd = cmd % (options.command, options.input, options.outputFastqsolexa)
  27. elif options.command == 'fq2fa':
  28. cmd = cmd % (options.command, options.input, options.outputFasta)
  29. try:
  30. os.system(cmd)
  31. except Exception, eq:
  32. stop_err("Error converting data format.\n" + str(eq))
  33. if __name__=="__main__": __main__()