morrislab / phylowgs

Application for inferring subclonal composition and evolution from whole-genome sequencing data.
GNU General Public License v3.0
108 stars 55 forks source link

Witness index_data.py cannot be called properly unless inside the folder #103

Open aleighbrown opened 5 years ago

aleighbrown commented 5 years ago

To make it easier to integrate into a pipeline:

Changing line 11 in index_data.py from base_dir = 'data' To base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),'data')

Allows you to call the file from outside the folder where the index_data.py script is located.

aleighbrown commented 5 years ago

And the witness viewer breaks if you do that, nvm.

aleighbrown commented 5 years ago

To force paths to be written in a relative manner so witness can read it as expected

base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),'data')

for run_name in os.listdir(base_dir): print(run_name) for summary_path in glob.glob(os.path.join(base_dir, run_name, '*.summ.json')): dataset_name = summary_path.split('/')[-1].split('.')[0]

  run = {
    `'summary_path': os.path.join('data', run_name, dataset_name + '.summ.json'),
    'muts_path': os.path.join('data', run_name, dataset_name + '.muts.json'),
    'name': dataset_name,`
  }

  `clusters_path = os.path.join('data', run_name, dataset_name + '.clusters.json')`
  if os.path.isfile(clusters_path):
    run['clusters_path'] = clusters_path

  `mutass_path = os.path.join('data', run_name, dataset_name + '.mutass')`
  if os.path.isdir(mutass_path):
    run['mutass_path'] = mutass_path

  datasets[run_name].append(run)

print(datasets) out_path = os.path.join(os.path.dirname(os.path.realpath(file)), 'data', 'index.json') with open(out_path, 'w') as outf: print(json.dumps(datasets), file=outf)

main()

quaidmorris commented 5 years ago

Awesome, thanks!

Do you want to put in a pull request with this change? That way Github can track your contributions!

Best, Quaid.