i have to parse two large text-files. Each file contains a String-Mapping from a local-identifier to a String-value. The local-identifier is in fact just a temporary key. Later the mapping should be from value(file1) to value(file2).
so what i did was:
- build HashMaps with the mappings in every file.
- by iterating over the keyset i build a hashmap which maps value(file1) to value(file2)
after that i had three HashMaps
- localid -> value(file1)
- localid -> value(file2)
- value(file1) -> value(file2)
What i did for verification was: for each localid
- a)get value(file1) out of Map 1
- b)get value(file2) out of Map 2
- c)get value(file2) out of Map3 with the key out of step a)
- d)compare value(file2)_b with value(file2)_c
what happens is that the two values in step d) are not equal in 15% of the key-value-pairs.
Actually there is some kind of System there... For example N2c changes into [N]2c, [nH]1c3c changes into n1c3c and (N) changes into ([NH])
is it possible that Java interprets the String as regular expressions or has anyone another idea?
thanks a lot
EDIT: ok here is some code^^ yeah this is more readable... sorry...
HashMap<String, String> idToFile1 = File1.getMapping();
HashMap<String, String> idToFile2 = File2.getMapping();
HashMap<String, String> file1ToFile2 = new HashMap<String, String>();
for(String localid : smilesfragments.keySet()){
inchiToSmiles.put(idToFile1.get(localid), idToFile2.get(localid));
}
for(String localid : idToFile1.keySet()){
String file1val = idToFile1.get(localid);
String file2val = idToFile2.get(localid);
if(!file2val.equals(file1ToFile2.get(file1val))){
System.err.println("mismatch!");
}
}
I get the mismatch in 15% of the cases