def read_tricol_bitscores(file_path, net1=None, net2=None, by='name', row_filter=None, **kwargs): if 'delimiter' not in kwargs: kwargs['delimiter'] = '\t' if row_filter is not None: rows = [ row for row in iter_csv(file_path, **kwargs) if row_filter(row) ] else: rows = [row for row in iter_csv(file_path, **kwargs)] return TricolBitscoreMatrix(rows, net1=net1, net2=net2, by=by)
def read_tsv_edgelist(*, path=None, string=None, header=False): if string is not None: return list( iter_csv_fd(io.StringIO(string), delimiter='\t', header=header)) elif path is not None: return list(iter_csv(path, delimiter='\t', header=header)) else: return None
def import_alignment(self, net1, net2, execution_dir, file_name='alignment-net1-net2.tab'): header = (net1.name, net2.name) align_path = path.join(execution_dir, file_name) return header, [(a.strip(), b.strip()) for a, b in iter_csv(align_path, delimiter='\t')]
def import_alignment(self, net1, net2, execution_dir, file_name='net1_net2.pinalog.nodes_algn.txt'): header = (net1.name, net2.name) align_path = path.join(execution_dir, file_name) return header, [ (a, b) for a, b, some_score in iter_csv(align_path, delimiter='\t') ]
def iter_alignment_ids(self, execution_dir, file_name='alignment-net1-net2.csv'): alignment_path = path.join(execution_dir, file_name) # ignore the first two lines, they seem to be comments csv_rows = iter_csv(alignment_path, delimiter=' ') csv_rows = islice(csv_rows, 2, None) for p1id, p2id in csv_rows: yield int(p1id), int(p2id)
def import_alignment(self, net1, net2, execution_dir, file_name='net1.tab-net2.tab.alignment'): align_path = path.join(execution_dir, file_name) alignment = [(a, b) for a, b in iter_csv( align_path, delimiter=' ', skipinitialspace=False) if a != '' and b != ''] header = (net1.name, net2.name) if net1.igraph.vcount() > net2.igraph.vcount(): alignment = [(b, a) for a, b in alignment] return header, alignment