Skip to content
Snippets Groups Projects
Commit c49c60a9 authored by Bienchen's avatar Bienchen
Browse files

Simplifying handling fasta

parent 46805eb0
No related branches found
No related tags found
No related merge requests found
...@@ -229,6 +229,12 @@ class PM3OptionsNamespace(object): ...@@ -229,6 +229,12 @@ class PM3OptionsNamespace(object):
helper.MsgErrorAndExit("'--fasta %s' requires " % ' '.join(argstr)+ helper.MsgErrorAndExit("'--fasta %s' requires " % ' '.join(argstr)+
"one argument prefixed with 'trg:' marking "+ "one argument prefixed with 'trg:' marking "+
"the target sequence name", 11) "the target sequence name", 11)
# check that 'trg:' has a string attached
if not len(trgname):
helper.MsgErrorAndExit("'--fasta %s' requires " % ' '.join(argstr)+
"argument 'trg:' defining the "+
"target sequence name, empty one "+
"found: '%s'" % ' '.join(argstr), 14)
return trgname, seqfile return trgname, seqfile
def _PostProcessAlignment(self): def _PostProcessAlignment(self):
...@@ -242,11 +248,6 @@ class PM3OptionsNamespace(object): ...@@ -242,11 +248,6 @@ class PM3OptionsNamespace(object):
if self.fasta: if self.fasta:
for src in self.fasta: for src in self.fasta:
trgname, seqfile = self._FetchAlnFromFastaOpt(src) trgname, seqfile = self._FetchAlnFromFastaOpt(src)
if not len(trgname):
helper.MsgErrorAndExit("'--fasta' requires argument "+
"'trg:' defining the "+
"target sequence name, empty one "+
"found: '%s'" % ' '.join(src), 14)
helper.FileExists("Alignment", 12, seqfile) helper.FileExists("Alignment", 12, seqfile)
is_gz = helper.FileGzip("Alignment", 13, seqfile) is_gz = helper.FileGzip("Alignment", 13, seqfile)
readfile = seqfile readfile = seqfile
......
...@@ -100,9 +100,9 @@ class PM3ArgParseTests(unittest.TestCase): ...@@ -100,9 +100,9 @@ class PM3ArgParseTests(unittest.TestCase):
with self.assertRaises(SystemExit) as ecd: with self.assertRaises(SystemExit) as ecd:
parser.Parse(['--fasta', 'trg:', 'bar']) parser.Parse(['--fasta', 'trg:', 'bar'])
self.assertEqual(ecd.exception.code, 14) self.assertEqual(ecd.exception.code, 14)
self.assertEqual(self.log.messages['ERROR'][0], "'--fasta' requires "+ self.assertEqual(self.log.messages['ERROR'][0], "'--fasta trg: bar' "+
"argument 'trg:' defining the target sequence name, "+ "requires argument 'trg:' defining the target "+
"empty one found: 'trg: bar'") "sequence name, empty one found: 'trg: bar'")
def testAddAlignemntSwapTrgPfx(self): def testAddAlignemntSwapTrgPfx(self):
# checking that we fail on empty 'trg:' prefix for arguments of # checking that we fail on empty 'trg:' prefix for arguments of
...@@ -113,9 +113,9 @@ class PM3ArgParseTests(unittest.TestCase): ...@@ -113,9 +113,9 @@ class PM3ArgParseTests(unittest.TestCase):
with self.assertRaises(SystemExit) as ecd: with self.assertRaises(SystemExit) as ecd:
parser.Parse(['--fasta', 'bar', 'trg:']) parser.Parse(['--fasta', 'bar', 'trg:'])
self.assertEqual(ecd.exception.code, 14) self.assertEqual(ecd.exception.code, 14)
self.assertEqual(self.log.messages['ERROR'][0], "'--fasta' requires "+ self.assertEqual(self.log.messages['ERROR'][0], "'--fasta bar trg:' "+
"argument 'trg:' defining the target sequence name, "+ "requires argument 'trg:' defining the target "+
"empty one found: 'bar trg:'") "sequence name, empty one found: 'bar trg:'")
def testAddAlignmentNoFile(self): def testAddAlignmentNoFile(self):
# check that we throw an error if a non-exisiting file is given # check that we throw an error if a non-exisiting file is given
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment