@@ -136,6 +136,10 @@ El infer_element_from_padded_name(const char* name) {
136
136
return find_element (name);
137
137
}
138
138
139
+ bool element_from_padded_name_is_ambiguous (const char * name) {
140
+ return name[0 ] != ' ' && name[3 ] != ' ' && !is_digit (name[0 ]) && !is_digit (name[1 ]);
141
+ }
142
+
139
143
// "28-MAR-07" -> "2007-03-28"
140
144
// (we also accept less standard format "28-Mar-2007" as used by BUSTER)
141
145
// We do not check if the date is correct.
@@ -694,15 +698,6 @@ void process_conn(Structure& st, const std::vector<std::string>& conn_records) {
694
698
if (record.length () < 57 )
695
699
continue ;
696
700
Connection c;
697
- // emulating names used in wwPDB mmCIFs (covaleN and metalcN)
698
- if (is_metal (find_element (&record[12 ])) ||
699
- is_metal (find_element (&record[42 ]))) {
700
- c.name = " metalc" + std::to_string (++metalc_count);
701
- c.type = Connection::MetalC;
702
- } else {
703
- c.name = " covale" + std::to_string (++covale_count);
704
- c.type = Connection::Covale;
705
- }
706
701
for (int i : {0 , 1 }) {
707
702
const char * t = record.c_str () + 30 * i;
708
703
AtomAddress& ad = (i == 0 ? c.partner1 : c.partner2 );
@@ -711,6 +706,23 @@ void process_conn(Structure& st, const std::vector<std::string>& conn_records) {
711
706
ad.atom_name = read_string (t + 12 , 4 );
712
707
ad.altloc = read_altloc (t[16 ]);
713
708
}
709
+ auto get_elem = [&](const char * name, const AtomAddress& ad) {
710
+ if (element_from_padded_name_is_ambiguous (name)) {
711
+ const_CRA cra = st.first_model ().find_cra (ad);
712
+ if (cra.atom )
713
+ return cra.atom ->element .elem ;
714
+ }
715
+ return infer_element_from_padded_name (name);
716
+ };
717
+ // emulating names used in wwPDB mmCIFs (covaleN and metalcN)
718
+ if (is_metal (get_elem (&record[12 ], c.partner1 )) ||
719
+ is_metal (get_elem (&record[42 ], c.partner2 ))) {
720
+ c.name = " metalc" + std::to_string (++metalc_count);
721
+ c.type = Connection::MetalC;
722
+ } else {
723
+ c.name = " covale" + std::to_string (++covale_count);
724
+ c.type = Connection::Covale;
725
+ }
714
726
c.asu = compare_link_symops (record, c.reported_sym );
715
727
if (record.length () > 73 ) {
716
728
if (record[4 ] == ' R' )
0 commit comments