Skip to content
Snippets Groups Projects
Commit 5f6bb28f authored by Simon Penel's avatar Simon Penel
Browse files

Version 0.1.14: Ajout la statistique 'longueur moyenne des introns'

parent 6cb058cb
No related branches found
No related tags found
No related merge requests found
[package]
name = "stats_on_gff3"
version = "0.1.13"
version = "0.1.14"
authors = ["Simon Penel <simon.penel@univ-lyon1.fr>"]
edition = "2021"
description ="Calculate statistics such as CDS GC3 ratio, intron GC ratio, flanking gene region GC ratio, first intron length, number of introns."
......
......@@ -77,6 +77,7 @@ struct Stats {
cds_gc3_rate : Option<f64>, // taux de GC3 dans les CDS
first_intron_length: Option<u64>, // longueur du 1er intron
all_introns_length: Option<u64>, // longueur cumulee de tous les introns
mean_intron_length: Option<u64>, // longueur moyenne de tous les introns
nb_introns: u8, // nombre d'introns
cds_length: Option<usize>, // longueur du CDS
}
......@@ -597,7 +598,7 @@ fn main() {
let mut output_stats_file_name = args.gff_path.to_str().expect("Pas de fichier gff3").to_owned();
output_stats_file_name.push_str(".statistics.csv");
let mut output = File::create(output_stats_file_name).expect("Impossible de creer le fichier");
writeln!(output, "Gene, Transcrit, GC ratio introns, GC ratio left, GC ratio right, GC3 ratio cds, first intron length, all introns length, CDS length, nb of introns ").expect("Impossible d'ecrire dans le fichier");
writeln!(output, "Gene, Transcrit, GC ratio introns, GC ratio left, GC ratio right, GC3 ratio cds, first intron length, all introns length, mean intron length, CDS length, nb of introns ").expect("Impossible d'ecrire dans le fichier");
// Sorties pour phyloscape
let mut output_gc3_file_name = args.gff_path.to_str().expect("Pas de fichier gff3").to_owned();
......@@ -625,6 +626,10 @@ fn main() {
output_all_len_intron_file_name.push_str(".all_introns_length.data");
let mut output_all_len_intron = File::create(output_all_len_intron_file_name).expect("Impossible de creer le fichier");
let mut output_mean_len_intron_file_name = args.gff_path.to_str().expect("Pas de fichier gff3").to_owned();
output_mean_len_intron_file_name.push_str(".mean_intron_length.data");
let mut output_mean_len_intron = File::create(output_mean_len_intron_file_name).expect("Impossible de creer le fichier");
let mut output_nb_intron_file_name = args.gff_path.to_str().expect("Pas de fichier gff3").to_owned();
output_nb_intron_file_name.push_str(".nb_introns.data");
let mut output_nb_intron = File::create(output_nb_intron_file_name).expect("Impossible de creer le fichier");
......@@ -990,6 +995,7 @@ fn main() {
let mut nb_introns = 0;
let mut first_intron_length:Option<u64> = None;
let mut all_introns_length:Option<u64> = None;
let mut mean_intron_length:Option<u64> = None;
if dico_transcript_introns.contains_key(&trans.transcript.to_string()) {
let introns = &dico_transcript_introns[&trans.transcript];
nb_introns = introns.len() as u8;
......@@ -1007,6 +1013,7 @@ fn main() {
};
};
all_introns_length = Some(cumulated);
mean_intron_length = Some(cumulated / nb_introns as u64);
} else {
eprintln!("Pas d'intron dans le transcrit {}",trans.transcript);
......@@ -1019,6 +1026,7 @@ fn main() {
cds_gc3_rate: gc3_ratio,
first_intron_length: first_intron_length,
all_introns_length: all_introns_length,
mean_intron_length: mean_intron_length,
nb_introns:nb_introns,
cds_length:Some(cds_length),
};
......@@ -1085,6 +1093,13 @@ fn main() {
},
None => {write!(output,", N/A").unwrap();}
}
match s.mean_intron_length {
Some(r) => {
write!(output,", {}",r).unwrap();
writeln!(output_mean_len_intron,"{} {}",simple_gene_name,r).unwrap();
},
None => {write!(output,", N/A").unwrap();}
}
match s.cds_length {
Some(r) => {
write!(output,", {}",r ).unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment