$support->log_stamped("$total_features_old_new$feature_type"."s found in both old and new assembly dbs ($perc_features\% in old assembly db found in new db)\n\n",1);
#count features which have the same length in the new db
$sql="select count(1) from mapping where feature_type = '".$feature_type."' and feature_found_in_new_db = 1 and old_length = new_length";
#count mappings where start and end match feature location in the new db by mapping quality (1-contains gaps, 2 - no gaps
$support->log_stamped("$total_same_length$feature_type"."s where feature length in the old assembly db is the same as in the new assembly db\n\n",2);
$sql="select count(1) as mapping_count,mapping_quality from mapping where feature_type = '".$feature_type."' and feature_found_in_new_db = 1 and old_length = new_length and new_start = mapping_start and new_end = mapping_end and (new_strand = mapping_strands or mapping_strands = 'both') and (mapping_chrs = new_chr or mapping_chrs like concat(new_chr,',%')) group by mapping_quality";
$support->log_stamped("$mapping_counts{$mapping_q}{'mapping_count'} $feature_type mappings $mapping_quality{$mapping_q} where feature length in the old assembly db is the same as in the new assembly db and mapping start and end matchfeature location in the new db ($perc\%)\n\n",3);
$support->log_stamped("total: $ok_mappings ok $feature_type mappings ($perc_mappings\%):\n\n",3);
}else{
$support->log_stamped("no $feature_type"."s found for chromosome $chr where feature length in the old assembly db is the same as in the new assembly db\n\n",2);
}
$sql="select count(1) from mapping where feature_type = '".$feature_type."' and feature_found_in_new_db = 1 and old_length != new_length";
$support->log_stamped("$total_diff_length$feature_type"."s found for chromosome $chr where feature length in the old assembly db is different than in the new assembly db\n\n",2);
#count features with different length in the new db where either mapping start or end match new feature start or end respectively, by mapping quality
$sql="select count(1) as mapping_count,mapping_quality from mapping where feature_type = '".$feature_type."' and feature_found_in_new_db = 1 and old_length != new_length and (new_start = mapping_start or new_end = mapping_end) and (new_strand = mapping_strands or mapping_strands = 'both') and (mapping_chrs = new_chr or mapping_chrs like concat(new_chr,',%')) group by mapping_quality";
$support->log_stamped("$mapping_counts{$mapping_q}{'mapping_count'} $feature_type mappings $mapping_quality{$mapping_q} found for chromosome where feature length in the old assembly db is different than in the new assembly db and either mapping start or end matches the gene location in the new db ($perc\%)\n\n",3);
#count features with different length in the new db where either mapping start or end is within the difference between old and new length from the new feature start or end respectively, by mapping quality
$sql="select count(1) as mapping_count,mapping_quality from mapping where feature_type = '".$feature_type."' and feature_found_in_new_db = 1 and old_length != new_length and (abs(new_start - mapping_start) <= abs(new_length - old_length) or abs(new_end - mapping_end) <= abs(new_length - old_length)) and new_start != mapping_start and new_end != mapping_end and (new_strand = mapping_strands or mapping_strands = 'both') and (mapping_chrs = new_chr or mapping_chrs like concat(new_chr,',%')) group by mapping_quality";
$support->log_stamped("$mapping_counts{$mapping_q}{'mapping_count'} $feature_type mappings $mapping_quality{$mapping_q} found for chromosome where feature length in the old assembly db is different than in the new assembly db and either mapping start or end is within the difference between old and new feature length from the new feature start or end, respectively ($perc\%)\n\n",3);
$support->log_stamped("total: $ok_mappings ok $feature_type mappings ($perc_mappings\%):\n\n",3);
$ok_mappings_1+=$ok_mappings;
}else{
$support->log_stamped("no $feature_type"."s found for chromosome $chr where feature length in the old assembly db is different than in the new assembly db\n\n",2);