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):
helper.MsgErrorAndExit("'--fasta %s' requires " % ' '.join(argstr)+
"one argument prefixed with 'trg:' marking "+
"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
def _PostProcessAlignment(self):
......@@ -242,11 +248,6 @@ class PM3OptionsNamespace(object):
if self.fasta:
for src in self.fasta:
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)
is_gz = helper.FileGzip("Alignment", 13, seqfile)
readfile = seqfile
......
......@@ -100,9 +100,9 @@ class PM3ArgParseTests(unittest.TestCase):
with self.assertRaises(SystemExit) as ecd:
parser.Parse(['--fasta', 'trg:', 'bar'])
self.assertEqual(ecd.exception.code, 14)
self.assertEqual(self.log.messages['ERROR'][0], "'--fasta' requires "+
"argument 'trg:' defining the target sequence name, "+
"empty one found: 'trg: bar'")
self.assertEqual(self.log.messages['ERROR'][0], "'--fasta trg: bar' "+
"requires argument 'trg:' defining the target "+
"sequence name, empty one found: 'trg: bar'")
def testAddAlignemntSwapTrgPfx(self):
# checking that we fail on empty 'trg:' prefix for arguments of
......@@ -113,9 +113,9 @@ class PM3ArgParseTests(unittest.TestCase):
with self.assertRaises(SystemExit) as ecd:
parser.Parse(['--fasta', 'bar', 'trg:'])
self.assertEqual(ecd.exception.code, 14)
self.assertEqual(self.log.messages['ERROR'][0], "'--fasta' requires "+
"argument 'trg:' defining the target sequence name, "+
"empty one found: 'bar trg:'")
self.assertEqual(self.log.messages['ERROR'][0], "'--fasta bar trg:' "+
"requires argument 'trg:' defining the target "+
"sequence name, empty one found: 'bar trg:'")
def testAddAlignmentNoFile(self):
# 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