Commit 39d1d475 authored by Fabrice Allain's avatar Fabrice Allain
Browse files

fix: removed unicode strings during convert part

parent bad36769
......@@ -72,7 +72,7 @@ def GetFile(input, output):
"""
getback = GetString(input)
print(u'writing the output to %s' % str(output))
print('writing the output to %s' % str(output))
outhandle = open(output, 'w')
outhandle.write(getback)
outhandle.close()
......@@ -97,7 +97,7 @@ def GetString(input):
"""
# message:
print(u'reading %s' % str(input))
print('reading %s' % str(input))
# ARIA2 print 'deleting comments'
# opening the filehandles, get one big string:
......@@ -142,8 +142,8 @@ def GetString(input):
# write warning, if there are still braces left:
if openbr.search(stuff) is not None:
print(u'WARNING: there are more { than }')
print('WARNING: there are more { than }')
if closebr.search(stuff) is not None:
print(u'WARNING: there are more } than {')
print('WARNING: there are more } than {')
inhandle.close()
return stuff
......@@ -11,6 +11,7 @@ from . import TextFile as TextFile
import os
import re
import string
#from builtins import str
from . import AminoAcid as AminoAcid
......@@ -275,7 +276,7 @@ class SequenceList:
"""
if os.path.exists(fileName):
print(u'reading sequence %s' % str(fileName))
print('reading sequence %s' % str(fileName))
self.fileName = fileName
else:
print(u'the file %s does not exist. Abort ReadSeq method.' %
......@@ -298,7 +299,7 @@ class SequenceList:
# catch all the numbers and non-standard amino acids:
if string.strip(aaoutlist[2]) == '':
print(u'could not understand: %s' % str(element[0:3]))
print(u'=> this is not included in the sequence!')
print('=> this is not included in the sequence!')
continue
# append in to the list attribute:
self.aalist.append(aaoutlist[1])
......@@ -308,9 +309,9 @@ class SequenceList:
def Stdout(self):
"""writes the list of aminoacids to stdout"""
print(u'the file %s contains the sequence:' % str(self.fileName))
print('the file %s contains the sequence:' % str(self.fileName))
for eachaa in self.aalist:
print(u'%s' % str(eachaa))
print('%s' % str(eachaa))
###############################################################################
......@@ -326,12 +327,12 @@ class SequenceList:
-------
"""
print(u'the file %s contains the sequence:' % str(self.fileName))
print('the file %s contains the sequence:' % str(self.fileName))
outS = ''
for eachaa in self.aalist:
outS = outS + AminoAcid.AminoAcid(eachaa)[0]
print(u'%s' % str(outS))
print(u'the sequence includes %s residues.' % str(len(self.aalist)))
print('%s' % str(outS))
print('the sequence includes %s residues.' % str(len(self.aalist)))
###############################################################################
def WriteFasta(self, outfile):
......@@ -351,10 +352,10 @@ class SequenceList:
try:
outhandle = TextFile.TextFile(outfile, 'w')
except IOError:
print(u'could not open the file %s' % str(outfile))
print(u'Abort WriteFasta method.')
print('could not open the file %s' % str(outfile))
print('Abort WriteFasta method.')
return
print(u'writing to the file: %s' % str(outfile))
print('writing to the file: %s' % str(outfile))
# for the comment use the fileName
# (if it's empty use 'SEQUENCELIST_OUTPUT'):
......@@ -392,10 +393,10 @@ class SequenceList:
try:
outhandle = TextFile.TextFile(outfile, 'w')
except IOError:
print(u'could not open the file %s' % str(outfile))
print(u'Abort WriteSeq method.')
print('could not open the file %s' % str(outfile))
print('Abort WriteSeq method.')
return
print(u'writing to the file: %s' % str(outfile))
print('writing to the file: %s' % str(outfile))
for eachaa in self.aalist:
outhandle.write(eachaa + '\n')
outhandle.close()
......@@ -418,10 +419,10 @@ class SequenceList:
try:
outhandle = TextFile.TextFile(outfile, 'w')
except IOError:
print(u'could not open the file %s' % str(outfile))
print(u'Abort WriteSeq method.')
print('could not open the file %s' % str(outfile))
print('Abort WriteSeq method.')
return
print(u'writing to the file: %s' % str(outfile))
print('writing to the file: %s' % str(outfile))
for eachaa in self.aalist:
outhandle.write(string.lower(eachaa) + '\n')
outhandle.close()
......@@ -444,10 +445,10 @@ class SequenceList:
try:
outhandle = TextFile.TextFile(outfile, 'w')
except IOError:
print(u'could not open the file %s' % str(outfile))
print(u'Abort WriteSeq1 method.')
print('could not open the file %s' % str(outfile))
print('Abort WriteSeq1 method.')
return
print(u'writing to the file: %s' % str(outfile))
print('writing to the file: %s' % str(outfile))
for eachaa in self.aalist:
outhandle.write(AminoAcid.AminoAcid(eachaa)[0])
outhandle.write('\n')
......@@ -530,10 +531,10 @@ class SequenceList:
try:
outhandle = TextFile.TextFile(fileName, 'w')
except IOError:
print(u'could not open the file %s' % str(fileName))
print(u'Abort WriteXML2File method.')
print('could not open the file %s' % str(fileName))
print('Abort WriteXML2File method.')
return
print(u'writing to the file: %s' % str(fileName))
print('writing to the file: %s' % str(fileName))
outhandle.write(outString)
outhandle.close()
......@@ -541,7 +542,7 @@ class SequenceList:
###############################################################################
def _DoesFileExist(fileName):
if os.path.exists(fileName) == 0:
print(u'WARNING: %s does not exist.' % str(fileName))
print('WARNING: %s does not exist.' % str(fileName))
return 0
return 1
......@@ -549,13 +550,13 @@ def _DoesFileExist(fileName):
###############################################################################
# test code:
if __name__ == "__main__":
print(u'testing module:')
print('testing module:')
SL = SequenceList()
SL.aalist = ['ARG', 'GLY', 'HIS', 'PRO', 'GLU', 'TYR', 'ASP', 'GLN']
print(u'1. The test sequence is:')
print('1. The test sequence is:')
print(SL.aalist)
print(u'\n2. The Stdout() method prints:')
print('\n2. The Stdout() method prints:')
SL.Stdout()
print(u'\n3. The XML output is:')
print('\n3. The XML output is:')
print(SL.WriteXML2String())
print(u'\ntest done. bye.')
print('\ntest done. bye.')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment