Show
Ignore:
Timestamp:
08/14/09 21:50:23 (3 years ago)
Author:
jgao
Message:

IDMapperText & IDMapperBiomart driver update,
IDMapperBiomart constructor with mart

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/corelib/src/org/bridgedb/file/IDMapperText.java

    r134 r156  
    4949            { 
    5050                // parse arguments to determine idsep and dssep 
    51                 // sample: dssep:\t,idsep:;,idsep:,@file:/localfile.txt 
     51                // sample: dssep=\t,idsep=;,idsep=,,transitivity=false@file:/localfile.txt 
    5252                // \t represents tab, \@ represents @ 
    5353                String  path = null; 
    5454                char[] dssep = null; 
    5555                char[] idsep = null; 
     56                boolean transitivity = false; 
    5657 
    5758                int idx = location.indexOf("@"); 
     
    8182 
    8283                        String config = location.substring(0, idx)+","; 
     84                        String prefixTran = "transitivity="; 
     85                        idx = config.indexOf(prefixTran); 
     86                        String tran = config.substring(idx+prefixTran.length()); 
     87                        if (tran.toLowerCase().startsWith("true")) { 
     88                            transitivity = true; 
     89                        } else if (tran.toLowerCase().startsWith("false")) { 
     90                            transitivity = false; 
     91                        } else { 
     92                            throw new IDMapperException( 
     93                                    "transivity can only be true or false"); 
     94                        } 
     95 
    8396                        dssep = parseConfig(config, "dssep"); 
    8497                        idsep = parseConfig(config, "idsep"); 
     
    88101                try 
    89102                { 
    90                         return new IDMapperText(new URL(path), dssep, idsep); 
     103                        return new IDMapperText(new URL(path), dssep, idsep, 
     104                                transitivity); 
    91105                } 
    92106                catch (MalformedURLException ex) 
     
    98112            private char[] parseConfig(String config, String head) { 
    99113                Set<Character> delimiters = new HashSet(); 
    100                 Pattern p = Pattern.compile(head+":(.|\\t|\\@),", Pattern.CASE_INSENSITIVE); 
     114                Pattern p = Pattern.compile(head+"=(.|\\t|\\@),", 
     115                        Pattern.CASE_INSENSITIVE); 
    101116                Matcher m = p.matcher(config); 
    102117                while (m.find()) {