Commit c820c7f1 authored by Marine Bergot's avatar Marine Bergot

Upload New File

parent ea458063
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#Attention : pour que ça fonctionne, il faut : sed -i 's/"//g' outrider.tsv
import sys
import csv
lines = [line.rstrip() for line in open(sys.argv[1])]
header = lines[0].split()
print(header)
liste_dijarn = lines[0].split()[1:]
matrice_count = {l.split()[0]: l.split()[1:] for l in lines[1:]}
outrider_file = [line.rstrip() for line in open(sys.argv[2])]
outrider_file = outrider_file[1:]
#comparaison des listes de gènes outrider vs matrix.all.counts
key_matrix = matrice_count.keys()
keys_outrider = set()
for line in outrider_file:
gene = line.split()[1]
keys_outrider.add(gene)
dijarn = line.split()[2]
position = liste_dijarn.index(dijarn)
count_norm = line.split()[8]
matrice_count[gene][position] = count_norm
to_remove = list(set(key_matrix) - set(keys_outrider))
for key in to_remove:
del matrice_count[key]
with open(sys.argv[3], "w" , newline='') as output_file:
writer = csv.writer(output_file, delimiter='\t')
writer.writerow(header)
for i in matrice_count:
to_write =[i]+ matrice_count[i]
writer.writerow(to_write)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment