Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cezar77 test scripts indentation #36

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
46 changes: 22 additions & 24 deletions test/scripts/test_checkm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,43 @@
import errno

if len(sys.argv) == 1:
print "Please provide a filename"
sys.exit()
print "Please provide a filename"
sys.exit()

# output file
outfile = sys.argv[1]

if not os.path.dirname(outfile) == '':
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise

f = open(outfile, 'w+')

# try to run checkM
try:
p1 = subprocess.Popen(['checkm'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = subprocess.Popen(['checkm'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Run the command
checkm = p1.communicate()
output = checkm[0]
error = checkm[1]
# Run the command
checkm = p1.communicate()
output = checkm[0]
error = checkm[1]
except OSError as o:
f.write('OSError: make sure checkM is installed properly' + '\n')
f.close()
sys.exit()
f.write('OSError: make sure checkM is installed properly' + '\n')
f.close()
sys.exit()
except:
f.write('Unexpected error: unable to run checkM' + '\n')
f.close()
sys.exit()
f.write('Unexpected error: unable to run checkM' + '\n')
f.close()
sys.exit()

# if we're still here, check error and print
if error == '':
f.write('CheckM ran without problems' + '\n')
else :
f.write('CheckM ran with some errors: ' + error + '\n')
f.write('CheckM ran without problems' + '\n')
else:
f.write('CheckM ran with some errors: ' + error + '\n')

f.close()


45 changes: 21 additions & 24 deletions test/scripts/test_checkm_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,43 @@
import errno

if len(sys.argv) == 1:
print("Please provide a filename")
sys.exit()
print("Please provide a filename")
sys.exit()

# output file
outfile = sys.argv[1]

if not os.path.dirname(outfile) == '':
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise

f = open(outfile, 'w+')

# try to run add_tax.py
try:
p1 = subprocess.Popen(['scripts/add_tax.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = subprocess.Popen(['scripts/add_tax.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Run the command
addtax = p1.communicate()
output = addtax[0]
error = addtax[1]
# Run the command
addtax = p1.communicate()
output = addtax[0]
error = addtax[1]
except OSError as o:
f.write('OSError: is scripts/add_tax.py in your PATH?' + '\n')
f.close()
sys.exit()
f.write('OSError: is scripts/add_tax.py in your PATH?' + '\n')
f.close()
sys.exit()
except:
f.write('Unexpected error: unable to run scripts/add_tax.py' + '\n')
f.close()
sys.exit()
f.write('Unexpected error: unable to run scripts/add_tax.py' + '\n')
f.close()
sys.exit()

# if we're still here, check error and print
if error.decode(sys.stdout.encoding) == '':
f.write('scripts/add_tax.py ran without problems' + '\n')
f.write('scripts/add_tax.py ran without problems' + '\n')
else:
f.write('scripts/add_tax.py ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')
f.write('scripts/add_tax.py ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')


f.close()


47 changes: 22 additions & 25 deletions test/scripts/test_diamond.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,43 @@
import errno

if len(sys.argv) == 1:
print("Please provide a filename")
sys.exit()
print("Please provide a filename")
sys.exit()

# output file
outfile = sys.argv[1]

if not os.path.dirname(outfile) == '':
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise

f = open(outfile, 'w+')

# try to run checkM
try:
p1 = subprocess.Popen(['diamond','help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = subprocess.Popen(['diamond','help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Run the command
allout = p1.communicate()
output = allout[0]
error = allout[1]
# Run the command
allout = p1.communicate()
output = allout[0]
error = allout[1]
except OSError as o:
f.write('OSError: make sure DIAMOND is installed properly' + '\n')
f.close()
sys.exit()
f.write('OSError: make sure DIAMOND is installed properly' + '\n')
f.close()
sys.exit()
except:
f.write('Unexpected error: unable to run DIAMOND' + '\n')
f.close()
sys.exit()
f.write('Unexpected error: unable to run DIAMOND' + '\n')
f.close()
sys.exit()

# if we're still here, check error and print
if error.decode(sys.stdout.encoding) == '':
f.write('DIAMOND ran without problems' + '\n')
else :
f.write('DIAMOND ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')
f.write('DIAMOND ran without problems' + '\n')
else:
f.write('DIAMOND ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')


f.close()


46 changes: 22 additions & 24 deletions test/scripts/test_diamond_bin_summary_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,43 @@
import errno

if len(sys.argv) == 1:
print("Please provide a filename")
sys.exit()
print("Please provide a filename")
sys.exit()

# output file
outfile = sys.argv[1]

if not os.path.dirname(outfile) == '':
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise

f = open(outfile, 'w+')

# try to run checkM
try:
p1 = subprocess.Popen(['scripts/add_tax_diamond.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = subprocess.Popen(['scripts/add_tax_diamond.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Run the command
allout = p1.communicate()
output = allout[0]
error = allout[1]
# Run the command
allout = p1.communicate()
output = allout[0]
error = allout[1]
except OSError as o:
f.write('OSError: is scripts/add_tax_diamond.py in your PATH?' + '\n')
f.close()
sys.exit()
f.write('OSError: is scripts/add_tax_diamond.py in your PATH?' + '\n')
f.close()
sys.exit()
except:
f.write('Unexpected error: unable to run scripts/add_tax_diamond.py' + '\n')
f.close()
sys.exit()
f.write('Unexpected error: unable to run scripts/add_tax_diamond.py' + '\n')
f.close()
sys.exit()

# if we're still here, check error and print
if error.decode(sys.stdout.encoding) == '':
f.write('scripts/add_tax_diamond.py ran without problems' + '\n')
else :
f.write('scripts/add_tax_diamond.py ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')
f.write('scripts/add_tax_diamond.py ran without problems' + '\n')
else:
f.write('scripts/add_tax_diamond.py ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')

f.close()


48 changes: 23 additions & 25 deletions test/scripts/test_diamond_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,43 @@
import errno

if len(sys.argv) == 1:
print("Please provide a filename")
sys.exit()
print("Please provide a filename")
sys.exit()

# output file
outfile = sys.argv[1]

if not os.path.dirname(outfile) == '':
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
if not os.path.exists(os.path.dirname(outfile)):
try:
os.makedirs(os.path.dirname(outfile))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise

f = open(outfile, 'w+')

# try to run checkM
try:
p1 = subprocess.Popen(['scripts/diamond_report.pl'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = subprocess.Popen(['scripts/diamond_report.pl'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Run the command
allout = p1.communicate()
output = allout[0]
error = allout[1]
# Run the command
allout = p1.communicate()
output = allout[0]
error = allout[1]
except OSError as o:
f.write('OSError: is scripts/diamond_report.pl in your PATH?' + '\n')
f.close()
sys.exit()
f.write('OSError: is scripts/diamond_report.pl in your PATH?' + '\n')
f.close()
sys.exit()
except:
f.write('Unexpected error: unable to run scripts/diamond_report.pl - is BioPerl installed?' + '\n')
f.close()
sys.exit()
f.write('Unexpected error: unable to run scripts/diamond_report.pl - is BioPerl installed?' + '\n')
f.close()
sys.exit()

# if we're still here, check error and print
if error.decode(sys.stdout.encoding) == '':
f.write('scripts/diamond_report.pl ran without problems' + '\n')
else :
f.write('scripts/diamond_report.pl ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')

f.close()

f.write('scripts/diamond_report.pl ran without problems' + '\n')
else:
f.write('scripts/diamond_report.pl ran with some errors: ' + error.decode(sys.stdout.encoding) + '\n')

f.close()
Loading