def genbank_view(params): for param in params: altname = resolve_fname(param.acc, format="gb") if os.path.isfile(param.acc): stream = utils.gz_read(param.acc) elif os.path.isfile(altname): stream = utils.gz_read(altname) else: stream = [] utils.error(f"data not found: {param.acc}") for line in stream: print(line, end='')
def parse_data(fname, study_size=10): """ Take a .gaf file and return an association dictionary and population dict. """ if not os.path.isfile(fname): utils.error("Association file needs to be downloaded first.") # Read the population from file association = {} population = set() stream = utils.gz_read(fname, 'r') print(f"*** parsing {fname}") # Get the gene from each row for line in stream: line = line.decode() if line.startswith('!'): continue gene = line.split('\t')[2] goterm = line.split('\t')[4] association.setdefault(gene, set()).update([goterm]) population.update([gene]) return population, association
def read_json_file(fname): """ Returns the content of a JSON file. """ fp = utils.gz_read(fname) data = json.load(fp) fp.close() return data