001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.bio.seq.io.agave; 022import org.biojava.bio.Annotation; 023 024/** 025 * Map EMBL data into AGAVE format 026 * 027 * @author Hanning Ni Doubletwist Inc 028 */ 029public class Embl2AgaveAnnotFilter extends SimpleAnnotFilter{ 030 031 public static final AGAVEAnnotFilterFactory EMBL_AGAVE_ANNOT_FILTER_FACTORY 032 = new AGAVEAnnotFilterFactory() { 033 public AGAVEAnnotFilter getInstance() { 034 return new Embl2AgaveAnnotFilter(); 035 } 036 }; 037 038 Embl2AgaveAnnotFilter() { 039 } 040 041 /** 042 * 043 */ 044 public String getAccession(Annotation annot) 045 { 046 return (String) UtilHelper.getProperty(annot,"AC"); 047 } 048 049 /** 050 * 051 */ 052 public String getKeyword(Annotation annot) 053 { 054 return (String) UtilHelper.getProperty(annot,"KW"); 055 } 056 057 /** 058 * 059 */ 060 public String getOrganism(Annotation annot) 061 { 062 return (String) UtilHelper.getProperty(annot,"OC"); 063 } 064 065 /** 066 * 067 */ 068 public String getDescription(Annotation annot) 069 { 070 return (String) UtilHelper.getProperty(annot,"DE"); 071 } 072 073 /** 074 * 075 */ 076 public String getNote(Annotation annot) 077 { 078 return 079 "RN:" +(String) UtilHelper.getProperty(annot,"RN") + " \n" + 080 "RP:" + (String) UtilHelper.getProperty(annot,"RP") + " \n" + 081 "RA:" + (String) UtilHelper.getProperty(annot,"RA") + " \n" + 082 "RT:" + (String) UtilHelper.getProperty(annot,"RT") + " \n" + 083 "RL:" + (String) UtilHelper.getProperty(annot,"RL") + " \n"; 084 } 085 086 /** 087 * 088 */ 089 public String getVersion(Annotation annot) 090 { 091 return (String) UtilHelper.getProperty(annot,"SV"); 092 } 093 094 /** 095 * 096 */ 097 public String getOS(Annotation annot) 098 { 099 return (String) UtilHelper.getProperty(annot,"OS"); 100 } 101 102 /** 103 * 104 */ 105 public String getMolType(Annotation annot) 106 { 107 String id = (String) UtilHelper.getProperty(annot,"ID"); 108 if (id.indexOf("rRNA") != -1) 109 { 110 return "rRNA"; 111 } 112 else if (id.indexOf("tRNA") != -1) 113 { 114 return "tRNA"; 115 } 116 else if (id.indexOf("mRNA") != -1) 117 { 118 return "mRNA"; 119 } 120 else if (id.indexOf("RNA") != -1) 121 { 122 return "RNA"; 123 } 124 else if (id.indexOf("cDNA") != -1) 125 { 126 return "cDNA"; 127 } 128 else if (id.indexOf("DNA") != -1) 129 { 130 return "DNA"; 131 } 132 else if (id.indexOf("PROTEIN") != -1) 133 { 134 return "AA"; 135 } 136 return null; 137 } 138 139 public AGAVEDbId getDbId(Annotation annot) 140 { 141 String AC = (String)UtilHelper.getProperty(annot,"AC") ; 142 String SV = (String)UtilHelper.getProperty(annot,"SV") ; 143 144 if( AC != null && SV != null ) 145 { 146 AGAVEDbId dbid = new AGAVEDbId() ; 147 dbid.setId( AC ) ; 148 dbid.setDbCode( SV ) ; 149 return dbid ; 150 } 151 else 152 return null ; 153 } 154 155}