本文整理汇总了Python中util.FileHandlers类的典型用法代码示例。如果您正苦于以下问题:Python FileHandlers类的具体用法?Python FileHandlers怎么用?Python FileHandlers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileHandlers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:7,代码来源:pdb.py
示例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)
开发者ID:AndreaEdwards,项目名称:phylogenetics_analysis_tools,代码行数:7,代码来源:run_raxml_dm_calulator.py
示例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
开发者ID:AndreaEdwards,项目名称:phylogenetics_analysis_tools,代码行数:29,代码来源:fix_names.py
示例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]
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:28,代码来源:pdb.py
示例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)
开发者ID:AndreaEdwards,项目名称:CAZy_phylogenetics,代码行数:7,代码来源:analysis_v4.py
示例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
开发者ID:AndreaEdwards,项目名称:phylogenetics_analysis_tools,代码行数:33,代码来源:fix_names.py
示例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
开发者ID:AndreaEdwards,项目名称:design_pipeline,代码行数:7,代码来源:seq.py
示例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
开发者ID:Hockstad,项目名称:design_pipeline,代码行数:31,代码来源:find_surface_res.py
示例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)
开发者ID:AndreaEdwards,项目名称:phylogenetics_analysis_tools,代码行数:7,代码来源:run_muscle.py
示例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])
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:8,代码来源:pdb.py
示例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
开发者ID:Hockstad,项目名称:design_pipeline,代码行数:10,代码来源:pdb.py
示例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
开发者ID:AndreaEdwards,项目名称:design_pipeline,代码行数:10,代码来源:stats.py
示例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
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:10,代码来源:pdb.py
示例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()
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:10,代码来源:pdb.py
示例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
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:10,代码来源:pdb.py
示例16: _get_data
def _get_data(self, file_tag):
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 self.filename == file_handlers.get_file_name(txt_file).split('_')[0]:
if (file_tag.split('_')[1] + '.txt') == file_handlers.get_file_name(txt_file).split('_')[1]:
TXT = open(txt_file)
self.data = TXT.readlines()
TXT.close()
开发者ID:cierrajanewalker,项目名称:design_pipeline,代码行数:10,代码来源:pdb.py
示例17: find_indices
def find_indices(path):
file_handlers = FileHandlers()
#for path in fasta_files:
indices = []
open_file = open(path, 'rU')
file_list = open_file.readlines()
for line in file_list:
if '>' in line:
indices.append(file_list.index(line))
interval = indices[1] - indices[0]
file_name = file_handlers.get_file_name(path)
return file_name, file_list, interval
开发者ID:AndreaEdwards,项目名称:CAZy_phylogenetics,代码行数:12,代码来源:analysis_v4.py
示例18: BuildRulesDict
def BuildRulesDict():
"""Construct a dictionary from the .rul file. Each key-value pair is
constructed from a single line of the .rul file The .rul file has the
following format:
this replace_this
R A G
Y C T
M A C
K G T
S C G
W A T
H A C T
B C G T
V A C G
D A G T
N A C G T
Parameters
----------
none
Returns
-------
rules_dict: dict
dictionary in which the key is a string resulting from joining the
nucleotides (A, G, C, T) in columns 2-5 of each line from the .rul
file and the value corresponds to the string in the first column of
each line of the .rul file
Examples
--------
>>> rules_dict = BuildRulesDict()
"""
file_handlers = FileHandlers()
rules_file = LoadFiles('rul')
rules_dict = {}
try:
for line in open(rules_file[0]):
fields = line.split("\t")
cleaned = file_handlers.clean(fields)
if ('this' and 'replace_this') in line:
pass
else:
if ''.join((cleaned[1:])) not in rules_dict:
rules_dict[''.join((cleaned[1:]))] = cleaned[0]
else:
pass
return rules_dict
except IOError:
print("An error occurred while trying to load the rules file." +
"Make sure the file is located in your current working directory.")
开发者ID:AndreaEdwards,项目名称:codon_compression,代码行数:52,代码来源:DYNAMCC_R.py
示例19: _get_outfile
def _get_outfile(self):
file_handlers = FileHandlers()
file_paths = file_handlers.search_directory()
out_files = file_handlers.find_files(file_paths, 'out')
if (self.pdb_code != '' and self.psiblast != ''):
for out_file in out_files:
if (self.pdb_code + '_mutants') == \
file_handlers.get_file_name(out_file).split('.')[0]:
self.ddG_results_filepath = out_file
elif (self.psiblast + '_mutants') == \
file_handlers.get_file_name(out_file).split('.')[0]:
self.llikelihood_filepath = out_file
elif (self.pdb_code != '' and self.psiblast == ''):
for out_file in out_files:
if (self.pdb_code + '_mutants') == \
file_handlers.get_file_name(out_file).split('.')[0]:
self.ddG_results_filepath = out_file
print "Fetching data from %s ....." % \
file_handlers.get_file_name(out_file)
elif (self.pdb_code == '' and self.psiblast != ''):
for out_file in out_files:
if (self.psiblast + '_mutants') == \
file_handlers.get_file_name(out_file).split('.')[0]:
self.llikelihood_filepath = out_file
else:
print "You have not specified any results data to parse."
exit(1)
开发者ID:kata9238,项目名称:bioverse,代码行数:27,代码来源:seq.py
示例20: BuildUsageDict
def BuildUsageDict():
"""Build a codon usage dictionary based on the user selected codon usage
file
Useful for downstream calculations involving known codon usage frequencies
in a given organism
Parameters
----------
none
Returns
-------
usage_dict: dict
Dictionary of lists of dictionaries for codon usage. Dictionary has the
following structure:
{
F : [{TTT: 0.58}, {TTC: 0.42}],
L : [{TTA: 0.14}, {TTG: 0.13}, {CTT: 0.12}, {CTC: 0.1},
{CTA: 0.04}, {CTG: 0.47}],
I : [{ATT: 0.49}, {ATC: 0.39}, {ATA: 0.11}],
...
...
...
G : [{GGT: 0.35}, {GGC: 0.37}, {GGA: 0.13}, {GGG: 0.15}]
}
Examples
--------
>>> usage_dict = BuildUsageDict()
"""
file_handlers = FileHandlers()
all_files = LoadFiles('txt')
selection_int, file_path, file_name = GetDataFile(all_files)
usage_dict = {}
try:
for line in open(file_path):
fields = line.split("\t")
cleaned = file_handlers.clean(fields)
if ('Codon' and 'name' and 'prob') in line:
pass
else:
if cleaned[1] in usage_dict:
usage_dict[cleaned[1]].append({cleaned[0]: cleaned[2]})
else:
usage_dict[cleaned[1]] = [{cleaned[0]: cleaned[2]}]
return usage_dict
except IOError:
print("An error occurred while trying to load the data file." +
"Make sure the file is located in your current working directory.")
开发者ID:AndreaEdwards,项目名称:codon_compression,代码行数:50,代码来源:DYNAMCC_R.py
注:本文中的util.FileHandlers类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论