+ def process_hmmscan_datas( hmmscan_datas,
+ in_msa,
+ add_position,
+ add_domain_number,
+ add_species,
+ out_msa,
+ out_msa_singles,
+ out_msa_pairs,
+ out_msa_isolated,
+ min_linker,
+ out_msa_single_domains_protein_seqs,
+ out_msa_close_pairs_protein_seqs,
+ out_msa_close_pairs_only_protein_seqs,
+ out_msa_isolated_protein_seqs,
+ out_msa_isolated_only_protein_seqs,
+ out_msa_isolated_and_close_pair_protein_seqs )
+
+ actual_out_of = hmmscan_datas.size
+ saw_close_pair = false
+ saw_isolated = false
+
+ seq_name = ""
+ prev_seq_name = nil
+
+ hmmscan_datas.each_with_index do |hmmscan_data, index|
+ if hmmscan_data.number < ( index + 1 )
+ error_msg = "hmmscan_data.number < ( index + 1 ) (this should not have happened)"
+ raise StandardError, error_msg
+ end
+
+ seq_name = hmmscan_data.seq_name
+
+ extract_domain( seq_name,
+ index + 1,
+ actual_out_of,
+ hmmscan_data.env_from,
+ hmmscan_data.env_to,
+ in_msa,
+ out_msa,
+ add_position,
+ add_domain_number,
+ add_species )
+
+ if min_linker
+ if actual_out_of == 1
+ extract_domain( seq_name,
+ 1,
+ 1,
+ hmmscan_data.env_from,
+ hmmscan_data.env_to,
+ in_msa,
+ out_msa_singles,
+ add_position,
+ add_domain_number,
+ add_species )
+ if out_msa_single_domains_protein_seqs.find_by_name_start( seq_name, true ).length < 1
+ add_sequence( seq_name, in_msa, out_msa_single_domains_protein_seqs )
+ else
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+
+ else
+ first = index == 0
+ last = index == hmmscan_datas.length - 1
+
+ if ( ( first && ( ( hmmscan_datas[ index + 1 ].env_from - hmmscan_data.env_to ) > min_linker) ) ||
+ ( last && ( ( hmmscan_data.env_from - hmmscan_datas[ index - 1 ].env_to ) > min_linker ) ) ||
+ ( !first && !last && ( ( hmmscan_datas[ index + 1 ].env_from - hmmscan_data.env_to ) > min_linker ) &&
+ ( ( hmmscan_data.env_from - hmmscan_datas[ index - 1 ].env_to ) > min_linker ) ) )
+
+ extract_domain( seq_name,
+ index + 1,
+ actual_out_of,
+ hmmscan_data.env_from,
+ hmmscan_data.env_to,
+ in_msa,
+ out_msa_isolated,
+ add_position,
+ add_domain_number,
+ add_species )
+ saw_isolated = true
+
+ elsif !first
+ extract_domain( seq_name,
+ index.to_s + "+" + ( index + 1 ).to_s,
+ actual_out_of,
+ hmmscan_datas[ index - 1 ].env_from,
+ hmmscan_data.env_to,
+ in_msa,
+ out_msa_pairs,
+ add_position,
+ add_domain_number,
+ add_species )
+ saw_close_pair = true
+ end
+ end
+ end
+ if prev_seq_name && prev_seq_name != seq_name
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+ prev_seq_name = seq_name
+ end # each
+ if saw_isolated
+ if out_msa_isolated_protein_seqs.find_by_name_start( seq_name, true ).length < 1
+ add_sequence( seq_name, in_msa, out_msa_isolated_protein_seqs )
+ else
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+ end
+ if saw_close_pair
+ if out_msa_close_pairs_protein_seqs.find_by_name_start( seq_name, true ).length < 1
+ add_sequence( seq_name, in_msa, out_msa_close_pairs_protein_seqs )
+ else
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+ end
+ if saw_close_pair && saw_isolated
+ if out_msa_isolated_and_close_pair_protein_seqs.find_by_name_start( seq_name, true ).length < 1
+ add_sequence( seq_name, in_msa, out_msa_isolated_and_close_pair_protein_seqs )
+ else
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+ elsif saw_close_pair
+ if out_msa_close_pairs_only_protein_seqs.find_by_name_start( seq_name, true ).length < 1
+ add_sequence( seq_name, in_msa, out_msa_close_pairs_only_protein_seqs )
+ else
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+ elsif saw_isolated
+ if out_msa_isolated_only_protein_seqs.find_by_name_start( seq_name, true ).length < 1
+ add_sequence( seq_name, in_msa, out_msa_isolated_only_protein_seqs )
+ else
+ error_msg = "this should not have happened"
+ raise StandardError, error_msg
+ end
+ end
+ end # def process_hmmscan_data
+