本文整理汇总了Python中util.FileHandlers类的典型用法代码示例。如果您正苦于以下问题:Python FileHandlers类的具体用法?Python FileHandlers怎么用?Python FileHandlers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileHandlers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_downloaded_file_path
def _get_downloaded_file_path(self, pdb_code):
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
ent_files = file_handlers.find_files(file_paths, 'ent')
for ent_file in ent_files:
if pdb_code == file_handlers.get_file_name(ent_file).split('.')[0].lstrip('pdb').upper():
return ent_file
示例2: main
def main():
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
fasta_files = file_handlers.find_files(file_paths, 'fasta')
for path in fasta_files:
file_name = file_handlers.get_file_name(path)
get_dm_raxml(path, file_name, 4)
示例3: __init__
class PickleFasta:
def __init__(self):
self.file_handlers = FileHandlers()
def _get_fasta_files(self):
file_paths = self.file_handlers.search_directory()
fasta_files = self.file_handlers.find_files(file_paths, 'faa')
print "There are %d .faa files in this directory" % len(fasta_files)
return fasta_files
def pickle_organism_fasta(self):
fasta_files = self._get_fasta_files()
fasta_dictionary = {}
for fasta_file in fasta_files:
file_name = self.file_handlers.get_file_name(fasta_file)
name_list = file_name.split('.')
Data = open(fasta_file)
D = Data.readlines()
Data.close()
for d in D:
if d.startswith('>'):
d_list = d.split(' ')
if name_list[0] in fasta_dictionary:
fasta_dictionary[name_list[0]].append(d_list[0].lstrip('>'))
else:
fasta_dictionary[name_list[0]] = [d_list[0].lstrip('>')]
else:
pass
return fasta_dictionary
示例4: _build_SASA_dict
def _build_SASA_dict(self):
file_handlers = FileHandlers()
self.SASA_dict[self.filename] = {}
self._run_POPS()
self._get_data()
for line in self.data:
fields = line.split('\t')
cleaned = file_handlers.clean(fields)
if len(cleaned) == 9:
(position,
aa,
tot_SA,
SASA,
frac_SASA,
phob,
phil) = (cleaned[2],
cleaned[0],
cleaned[8],
cleaned[5],
cleaned[6],
cleaned[3],
cleaned[4])
self.SASA_dict[self.filename][position] = [aa,
tot_SA,
SASA,
frac_SASA,
phob,
phil]
示例5: main
def main():
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
fasta_files = file_handlers.find_files(file_paths, 'fasta')
for path in fasta_files:
file_name, file_list, interval = find_indices(path)
write_fasta_new_names(path, file_name, file_list, interval)
示例6: main
def main():
## THIS WORKED, DON'T ERASE
## Save organism data to pickled dictionary
#pickle_fasta = PickleFasta()
#fasta_dictionary = pickle_fasta.pickle_organism_fasta()
#print "There are %d entries in the fasta_dictionary" % len(fasta_dictionary)
#pickle.dump(fasta_dictionary, open('organism_dictionary.pkl', 'wb'))
file_handlers = FileHandlers()
dm_files = get_dm_files()
# Load the dictionary back from the pickle file
print "Loading fasta_dictionary..."
open_fasta = open('organism_dictionary.pkl', 'rb')
fasta_dictionary = pickle.load(open_fasta)
open_fasta.close()
print "Length of fasta dictionary: ", len(fasta_dictionary)
## THIS WORKED, DON'T ERASE
## Build mapping dictionary and pickle
dm_processing = dmDictionary()
dm_processing.init_mapping_dictionary(fasta_dictionary)
for path in dm_files:
file_name = file_handlers.get_file_name(path)
print "Opening %s..." % file_name
dm_dictionary = dm_processing.individual_dm_dictionary(path, file_name)
print "Length of dm_dictionary for %s is %d" % (file_name, len(dm_dictionary))
mapping_dictionary = dm_processing.build_mapping_dictionary(fasta_dictionary, dm_dictionary)
open_mapping = open('mapping_dictionary.pkl', 'wb')
pickle.dump(mapping_dictionary, open_mapping)
open_mapping.close()
print mapping_dictionary
示例7: _get_pdb_file_path
def _get_pdb_file_path(self):
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
pdb_files = file_handlers.find_files(file_paths, 'pdb')
for pdb_file in pdb_files:
if (self.filename + '_0001') == file_handlers.get_file_name(pdb_file).split('.')[0]:
self.file_path = pdb_file
示例8: build_SASA_dict
def build_SASA_dict(out_files):
SASA_dict = {}
for path in out_files:
file_handlers = FileHandlers()
file_name = file_handlers.get_file_name(path)
SASA_dict[file_name] = {}
for line in open(path):
file_handlers2 = FileHandlers()
fields = line.split('\t')
cleaned = file_handlers2.clean(fields)
if len(cleaned) == 9: #and int(cleaned[2]) >= 1:
(position,
aa,
tot_SA,
SASA,
frac_SASA,
phob,
phil) = (cleaned[2],
cleaned[0],
cleaned[8],
cleaned[5],
cleaned[6],
cleaned[3],
cleaned[4])
SASA_dict[file_name][position] = [aa,
tot_SA,
SASA,
frac_SASA,
phob,
phil]
return SASA_dict
示例9: main
def main():
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
pep_files = file_handlers.find_files(file_paths, "pep")
for pep_file in pep_files:
file_name = file_handlers.get_file_name(pep_file)
run_muscle(pep_file, file_name)
示例10: _build_data_dict
def _build_data_dict(self, file_tag):
self.data_dict = {}
self._get_data(file_tag)
file_handlers = FileHandlers()
for line in self.data:
fields = line.split('\t')
cleaned = file_handlers.clean(fields)
self.data_dict[cleaned[0]] = float(cleaned[1])
示例11: _open_file
def _open_file(self):
#os.chdir("../src/database/pdbs")
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
pdb_files = file_handlers.find_files(file_paths, 'pdb')
for pdb_file in pdb_files:
if self.filename == file_handlers.get_file_name(pdb_file).split('.')[0]:
Data = open(pdb_file)
self.data = Data.readlines()
Data.close
示例12: _get_data
def _get_data(self, filename):
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
txt_files = file_handlers.find_files(file_paths, 'txt')
for txt_file in txt_files:
if filename == file_handlers.get_file_name(txt_file):
TXT = open(txt_file)
data = TXT.readlines()
TXT.close()
return data
示例13: _get_output
def _get_output(self):
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
out_files = file_handlers.find_files(file_paths, 'out')
for out_file in out_files:
TXT = open(out_file)
data = TXT.readlines()
TXT.close()
os.remove(out_file)
return data
示例14: _get_pdb
def _get_pdb(self):
#os.chdir("./database/pdbs/pdb")
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
pdb_files = file_handlers.find_files(file_paths, 'pdb')
for pdb_file in pdb_files:
if self.filename == file_handlers.get_file_name(pdb_file).split('.')[0]:
PDB = open(pdb_file)
self.pdb = PDB.readlines()
PDB.close()
示例15: _get_file_path
def _get_file_path(self):
os.chdir("./database/pdbs/pdb")
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
pdb_files = file_handlers.find_files(file_paths, 'pdb')
for pdb_file in pdb_files:
if (self.filename + '_0001') == file_handlers.get_file_name(pdb_file).split('.')[0]:
self.file_path = pdb_file
self.out_file = file_handlers.get_file_name(pdb_file).split('.')[0] + '_pops.out'
self.out_file_path = self.dir_path + '/' + self.out_file