String code = c.getCode();
// save term information in MRCONSO
// C0000005|ENG|P|L0187013|PF|S2192303|Y|A4332670||M0019694|D012711|MSH|EN|D012711|(131)I-MAA|0|N||
for(Term t: c.getTerms()){
Source src = t.getSource();
if(src == null && c.getSources().length > 0)
src = c.getSources()[0];
String lat = t.getLanguage() == null?"ENG":t.getLanguage();
String ts = t.isPreferred()?"P":"S";
String lui = getLUI(t.getText());
String stt = t.isPreferred()?"PF":"VO";
String sui = getSUI(t.getText());
String pref = t.isPreferred()?"Y":"N";
String aui = String.format("A%07d",atomCount);
String saui = "";
String scui = "";
String sdui = "";
String sab = src != null?src.getName():"";
String tty = t.getForm() != null?t.getForm():"SY";
String scode = (c.getCodes() != null && src != null && c.getCodes().containsKey(src))?""+c.getCodes().get(src):cui;
String str = t.getText();
String srl = "0";
String sup = "N";
String cvf = "";
// write out
mrconso.write(cui+I+lat+I+ts+I+lui+I+stt+I+sui+I+pref+I+aui+I+saui+I+scui+I+sdui+I+sab+I+tty+I+scode+I+str+I+srl+I+sup+I+cvf+"\n");
mrconso.flush();
atomCount ++;
}
// save MRDEF information in MRDEF
// C0000107|A3857241|AT22515555||MSH|An ANGIOTENSIN II analog which acts as a highly specific inhibitor of ANGIOTENSIN TYPE 1 RECEPTOR.|N||
for(Definition d: c.getDefinitions()){
Source src = d.getSource();
if(src == null && c.getSources().length > 0)
src = c.getSources()[0];
String aui = "";
String atui = "";
String satui = "";
String sab = src != null?src.getName():"";
String def = d.getDefinition();
String sup = "N";
String cvf = "";
mrdef.write(cui+I+aui+I+atui+I+satui+I+sab+I+def+I+sup+I+cvf+"\n");
mrdef.flush();
}
// save MRSTY information
// C0000005|T121|A1.4.1.1.1|Pharmacologic Substance|AT16627324||
for(SemanticType st: c.getSemanticTypes()){
String tui = getTUI(st);
String stn = "";
String sty = st.getName();
String atui = "";
String cvf = "";
mrsty.write(cui+I+tui+I+stn+I+sty+I+atui+I+cvf+"\n");
mrsty.flush();
}
// add to sources
Collections.addAll(sources,c.getSources());
// save terminology
if(term == null && c.getTerminology() != null)
term = c.getTerminology();
// keep track of translation
codes.write(cui+"="+code+"\n");
codes.flush();
}
// if possible use sources from terminology, cuase they have more data
if(term != null && term.getSources().length > 0){
Set<Source> tsources = new TreeSet<Source>();
for(Source s: term.getSources()){
if(sources.contains(s)){
tsources.add(s);
}
}
sources = tsources;
}
// write out sources
// CL432995|C1140168|NCI2011_12E|NCI|National Cancer Institute Thesaurus, 2011_12E|NCI|2011_12E|||201112||
// Sherri de Coronado;Center for Bioinformatics, National Cancer Institute;2115 E. Jefferson St.;6th Floor;
// Rockville;MD;USA;20892-8335;925-377-5960;decorons@osp.nci.nih.gov|Sherri de Coronado;Center for Bioinformatics,
// National Cancer Institute;2115 E. Jefferson St.;6th Floor;Rockville;MD;USA;20892-8335;925-377-5960;decorons@osp.nci.nih.gov
// |0|205092|87562|FULL-NOSIB-MULTIPLE-IGNORE-RELA|AB,AD,BN,CA2,CA3,CCN,CCS,CNU,CSN,DN,FBD,HD,OP,PT,SY|
// Accepted_Therapeutic_Use_For,BioCarta_ID,CAS_Registry,CHEBI_ID,Chemical_Formula,Contributing_Source,Design_Note,
// EntrezGene_ID,Essential_Amino_Acid,Essential_Fatty_Acid,Extensible_List,FDA_Table,FDA_UNII_Code,GO_Annotation,
// GenBank_Accession_Number,Gene_Encodes_Product,Homologous_Gene,ICD-O-3_Code,INFOODS,KEGG_ID,MGI_Accession_ID,
// Macronutrient,Micronutrient,NCBI_Taxon_ID,NSC_Code,Neoplastic_Status,Nutrient,OMIM_Number,PDQ_Closed_Trial_Search_ID,
// PDQ_Open_Trial_Search_ID,PID_ID,PubMedID_Primary_Reference,Swiss_Prot,Tolerable_Level,USDA_ID,US_Recommended_Intake,Unit,
// Use_For,miRBase_ID|ENG|UTF-8|Y|Y|NCI Thesaurus|National Cancer Institute, National Institutes of Health;NCI Thesaurus;
// Sherri de Coronado, decorons@osp.nci.nih.gov;December 2011, Protege version;Rockville, MD|
for(Source src : sources){
String def = src.getDescription();
if(def != null){
int x = def.indexOf(".");
if(x > -1){
def = def.substring(0,x);
}
}
String vcui = "";
String rcui = src.getCode() != null?src.getCode():"";
String vsab = "";// versioned abbreviation
String rsab = src.getName(); // abbreviation
String son = def != null?def:""; // official name
String sf = src.getName(); // source family
String sver = "";
String vstart = "";
String vend = "";
String imeta ="";
String rmeta = "";
String slc = "";
String scc = "";
String srl = "0";
String tfr = ""; //term frequence
String cfr = ""; // concept frequency
String cxty = "";
String ttyl = "";
String atnl = "";
String lat = "ENG";
String cenc = "UTF-8";
String curver = "Y";
String sabin = "Y";
String ssn = son;
String scit= src.getDescription();
mrsab.write(vcui+I+rcui+I+vsab+I+rsab+I+son+I+sf+I+sver+I+vstart+I+vend+I+imeta+I+rmeta+I+slc+I+scc+I+srl+I+tfr+I+cfr+
I+cxty+I+ttyl+I+atnl+I+lat+I+cenc+I+curver+I+sabin+I+ssn+I+scit+"\n");
}