Exemplo n.º 1
0
 def test_parse_vdj_paths_with_ref(self):
     """parse_vdj_paths should work with builtin filename fragments"""
     shared = {
         "fasta": True,
         "input": str(self.path / "input"),
         "type": "dir"
     }
     attrs_list_exp = [{
         "path": self.path / "input/D.fasta",
         "segment": "D"
     }, {
         "path": self.path / "input/J.fasta",
         "segment": "J"
     }, {
         "path": self.path / "input/V.fasta",
         "segment": "V"
     }]
     for attrs in attrs_list_exp:
         attrs.update(shared)
     for locus_segment in sorted(
         ["IGHV", "IGHD", "IGHJ", "IGKV", "IGKJ", "IGLV", "IGLJ"]):
         attrs_list_exp.append({
             'fasta': True,
             'type': 'internal',
             'input': 'rhesus/imgt',
             'locus': locus_segment[:3],
             'path': DATA /
             f"germ/rhesus/imgt/{locus_segment[:3]}/{locus_segment}.fasta",
             'ref': 'imgt',
             'segment': locus_segment[3],
             'species': 'rhesus'
         })
     attrs_list = vdj.parse_vdj_paths([self.path / "input", "rhesus/imgt"])
     self.assertEqual(attrs_list, attrs_list_exp)
Exemplo n.º 2
0
 def test_parse_vdj_paths_duplicates(self):
     """parse_vdj_paths shouldn't repeat paths that come from multiple input names"""
     # Instead it'll just squish both input names into the same entries.
     shared = {
         "fasta": True,
         "input": str(self.path / "input"),
         "type": "dir"
     }
     attrs_list_exp = [{
         "path": self.path / "input/D.fasta",
         "segment": "D"
     }, {
         "path": self.path / "input/J.fasta",
         "segment": "J"
     }, {
         "path": self.path / "input/V.fasta",
         "segment": "V"
     }]
     for attrs in attrs_list_exp:
         attrs.update(shared)
     ref_paths = [self.path / "input", self.path / "input/D.fasta"]
     attrs_list_exp[0]["type"] = "file"
     attrs_list_exp[0]["input"] = "; ".join([str(p) for p in ref_paths])
     attrs_list = vdj.parse_vdj_paths(ref_paths)
     self.assertEqual(attrs_list, attrs_list_exp)
Exemplo n.º 3
0
 def test_parse_vdj_paths(self):
     """parse_vdj_paths should give a list of dicts with info parsed from the given paths"""
     shared = {
         "fasta": True,
         "input": str(self.path / "input"),
         "type": "dir"
     }
     attrs_list_exp = [{
         "path": self.path / "input/D.fasta",
         "segment": "D"
     }, {
         "path": self.path / "input/J.fasta",
         "segment": "J"
     }, {
         "path": self.path / "input/V.fasta",
         "segment": "V"
     }]
     for attrs in attrs_list_exp:
         attrs.update(shared)
     # It should be able to take Path objects, strings, or lists
     ref_path_inputs = [
         self.path / "input",
         str(self.path / "input"), [self.path / "input"]
     ]
     for ref_paths in ref_path_inputs:
         attrs_list = vdj.parse_vdj_paths(ref_paths)
         self.assertEqual(attrs_list, attrs_list_exp)
Exemplo n.º 4
0
 def test_parse_vdj_paths_with_files(self):
     """parse_vdj_paths should work with filenames as inputs"""
     # In this case they're sorted as they're given, since the sorting is
     # by-ref and then by-file.
     mkdict = lambda s: {
         "path": self.path / f"input/{s}.fasta",
         "input": str(self.path / f"input/{s}.fasta"),
         "segment": s,
         "fasta": True,
         "type": "file"
     }
     attrs_list_exp = [mkdict(s) for s in ["V", "D", "J"]]
     paths = [
         self.path / f"input/{segment}.fasta"
         for segment in ["V", "D", "J"]
     ]
     attrs_list = vdj.parse_vdj_paths(paths)
     self.assertEqual(attrs_list, attrs_list_exp)
Exemplo n.º 5
0
 def test_parse_vdj_paths(self):
     with self.assertRaises(IgSeqError):
         vdj.parse_vdj_paths(self.path / "missing")