#!/usr/bin/python # Copyright 2014 BARRIOT Roland # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import argparse import time import numpy as np import h5py from Prioritization import ScoreMatrix # SCRIPT PARAMETERS parser = argparse.ArgumentParser(description='ScoreMatrix initialization') parser.add_argument('--file', required=True, help='ScoreMatrix file to create.') parser.add_argument('--strain', required=True, help='Genome to fetch from CGDB.') parser.add_argument('--datasource', default='unspecified', required=False, help='Datasource.') parser.add_argument('--date', default=time.strftime('%Y-%m-%d'), required=False, help='Date of creation.') parser.add_argument('--comment', default='no comment.', required=False, help='Some comments.') parser.add_argument('--mode', default='alaR', required=False, help='Some comments.') parser.add_argument('--ids', required=True, help='File containing identifiers.') param = parser.parse_args() info = { 'strain': param.strain, 'datasource': param.datasource, 'date': param.date, 'comment': param.comment, 'mode': 'distance', 'representation': 'alaR' } sm = ScoreMatrix() sm.labels = {} with open(param.ids) as f: content = f.read() lines = content.split('\n') for i in xrange(len(lines)): sm.labels[lines[i]]=i sm.matrix = np.empty( i*(i-1)/2, dtype=np.float32) sm.matrix[:] = np.NAN sm.save(param.file, info)