Parsers

pytadbit.parsers.hic_parser.read_matrix(things, parser=None)[source]

Read and checks a matrix from a file or a list.

Parameters:
  • things – might be either a file name, a file handler, a list of them or a list of list (all with same length)
  • parser (None) –

    a parser function that returns a tuple of lists representing the data matrix, with this file example.tsv:

    chrT_001      chrT_002        chrT_003        chrT_004
    chrT_001      629     164     88      105
    chrT_002      86      612     175     110
    chrT_003      159     216     437     105
    chrT_004      100     111     146     278

    the output of parser(‘example.tsv’) might be: ([629, 86, 159, 100, 164, 612, 216, 111, 88, 175, 437, 146, 105, 110, 105, 278])

Returns:

the corresponding matrix concatenated into a huge list, also returns number or rows

pytadbit.parsers.tad_parser.parse_tads(handler)[source]

Parse a tab separated value file that contains the list of TADs of a given experiment. This file might have been generated whith the pytadbit.tadbit.print_result_R() or with the R binding for tadbit

Parameters:
  • handler – path to file
  • bin_size (1) – resolution of the experiment
Returns:

list of TADs, each TAD being a dict of type:

{TAD_num: {'start': start,
           'end'  : end,
           'brk'  : end,
           'score': score}}