Esempio n. 1
0
 def test_type_generator_valid(self):
     profiles = Profiles(os.path.join(data_dir, 'initial_profiles.txt'),
                         False)
     p = GATProfile(False,
                    fragments=['1', '7\'', '6\'', '4\'', '5\'', '3', '2\''])
     tg = TypeGenerator(profiles, p, False, prefix='GS')
     self.assertEqual(2, tg.calculate_orientationless_order())
     self.assertEqual('GS2.122', tg.calculate_type())
Esempio n. 2
0
 def test_type_generator_valid_seen(self):
     profiles = Profiles(os.path.join(data_dir, 'initial_profiles.txt'),
                         False)
     p = GATProfile(False, fragments=['1', '2', '3', '5', '4', '6', '7'])
     tg = TypeGenerator(profiles, p, False, True, prefix='GS')
     self.assertEqual(2, tg.calculate_orientationless_order())
     self.assertEqual('GREEN', tg.quality)
     self.assertEqual('GS2.0', tg.calculate_type())
Esempio n. 3
0
    def calc_type(self):
        profile_db = Profiles(os.path.join(self.db_dir, 'profile.txt'))

        split_fragments = self.fragments.split('-')
        input_profile = GATProfile(fragments=split_fragments)

        tg = TypeGenerator(profile_db, input_profile)
        return tg.calculate_type()
Esempio n. 4
0
    def __init__(self, options):
        self.socru_output_filename = options.socru_output_filename
        self.profile_filename = options.profile_filename
        self.output_file = options.output_file

        shutil.copy(self.profile_filename, self.output_file)
        self.profiles = Profiles(self.profile_filename)
        self.results = Results(self.socru_output_filename)
Esempio n. 5
0
    def test_profiles(self):
        p = Profiles(os.path.join(data_dir, 'profile.txt'), False)
        self.assertEqual(7, len(p.gats))
        self.assertEqual("1	2	3	4	5	6	7", str(p.gats[0]))

        p.gats[0].fragments = p.gats[0].invert_fragments()
        self.assertEqual("1'	7'	6'	5'	4'	3'	2'", str(p.gats[0]))

        self.assertEqual(5, p.dnaA_fragment_number)
Esempio n. 6
0
 def run(self):
     # load the profiles
     p = Profiles(os.path.join(self.db_dir, 'profile.txt'))
     d = Database(self.db_dir)
     
     for i in self.input_files:
         output_type = self.run_analysis(i, p, d)
         self.output_results(i, output_type)
         
     if self.top_blast_hits is not None:
         with open(self.top_blast_hits, "a+") as output_fh:
             for h in self.top_results:
                 output_fh.write(str(h)+"\n")
Esempio n. 7
0
    def type_generator(self):
        profile_db = Profiles(os.path.join(self.db_dir, 'profile.txt'),
                              self.verbose)

        split_fragments = self.fragments.split('-')
        input_profile = GATProfile(
            self.verbose,
            fragments=split_fragments,
            dnaA_fragment_number=profile_db.dnaA_fragment_number,
            dif_fragment_number=profile_db.dif_fragment_number)
        input_profile.orientate_for_dnaA()

        is_profile_valid = self.validate_profile(profile_db, input_profile)
        tg = TypeGenerator(profile_db, input_profile, self.verbose,
                           is_profile_valid)
        return tg
Esempio n. 8
0
 def run(self):
     # load the profiles
     if self.verbose:
         print("Loading profiles:\t" + os.path.join(self.db_dir, 'profile.txt'))
     p = Profiles(os.path.join(self.db_dir, 'profile.txt'), self.verbose)
     
     if self.verbose:
         print("Loading database:\t" + self.db_dir)
     d = Database(self.db_dir, self.verbose)
     
     for i in self.input_files:
         if self.verbose:
             print("Beginning analysis of input file:\t" + i)
         output_type = self.run_analysis(i, p, d)
         self.output_results(i, output_type)
         
     if self.top_blast_hits is not None:
         with open(self.top_blast_hits, "a+") as output_fh:
             for h in self.top_results:
                 output_fh.write(str(h)+"\n")