from .intersect import Features # functions to output the stats on the transfer # stats about missing segments and feature type, not used, will change. def stats_feature_missing_segment(feature_missing_segments,first_seg,last_seg,list_seg,feature_id,walk,segments_on_target_genome): # [feature_missing_first,feature_missing_middle,feature_missing_last,feature_missing_all,feature_missing_total,feature_total,feature_ok] feature_missing_segments[5].append(feature_id) if first_seg=='' : # no segment of the feature is in the genome, the feature is missing entirely feature_missing_segments[3].append(feature_id) elif first_seg != list_seg[0]: # the first segment is missing feature_missing_segments[0].append(feature_id) elif last_seg!=list_seg[-1]: # the last segment is missing feature_missing_segments[2].append(feature_id) # go through all the segments, check if some are missing in the middle of the feature elif (len(list_seg)!=1) and (feature_id not in feature_missing_segments[3]): # to access the second to last element for segment in list_seg[1-(len(list_seg)-2)]: if (segment not in segments_on_target_genome) or (walk not in segments_on_target_genome[segment]): feature_missing_segments[1].append(feature_id) break # go through the segments, to see if one is missing anywhere on the feature for segment in list_seg: if (segment not in segments_on_target_genome) or (walk not in segments_on_target_genome[segment]): if feature_id not in feature_missing_segments[4]: feature_missing_segments[4].append(feature_id) break # if the feature doesnt have a missing segment, it is complete. ADD THE PATH CHECK FOR INSERTIONS !! if feature_id not in feature_missing_segments[4]: feature_missing_segments[6].append(feature_id) def get_annot_features(list_features): list_annot_features=[] for feature in list_features: list_annot_features.append(Features[feature].note) return list_annot_features def count_hypput_total(list_annot_first): total=len(list_annot_first) count_hypput=0 for annot in list_annot_first: if ("hypothetical" in annot) or ("putative" in annot): count_hypput+=1 return [count_hypput,total] # print stats on the transfer : number of feature that have segments in different positions missing. def stats_features(feature_missing_segments): # [feature_missing_first,feature_missing_middle,feature_missing_last,feature_missing_all,feature_missing_total,feature_total,feature_ok] list_annot_first=get_annot_features(feature_missing_segments[0]) [hyp_put,total]=count_hypput_total(list_annot_first) print("\nthe first segment is missing for", total,"features, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.") list_annot_middle=get_annot_features(feature_missing_segments[1]) [hyp_put,total]=count_hypput_total(list_annot_middle) print("a middle segment is missing for", total,"features, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.") list_annot_last=get_annot_features(feature_missing_segments[2]) [hyp_put,total]=count_hypput_total(list_annot_last) print("the last segment is missing for", total,"features, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.") list_annot_all=get_annot_features(feature_missing_segments[3]) [hyp_put,total]=count_hypput_total(list_annot_all) print(total,"features are entirely missing, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.") list_annot_total=get_annot_features(feature_missing_segments[4]) [hyp_put,total]=count_hypput_total(list_annot_total) print("there is at least one segment missing for", total,"features, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.") list_annot_ok=get_annot_features(feature_missing_segments[6]) [hyp_put,total]=count_hypput_total(list_annot_ok) print(total ,"features are entirely present in the new genome, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.") list_annot_features=get_annot_features(feature_missing_segments[5]) [hyp_put,total]=count_hypput_total(list_annot_features) print("there is", total,"features in total, including",round(100*(hyp_put)/total,2),"% hypothetical or putative.")