use of org.nextprot.api.core.domain.IsoformSpecificity in project nextprot-api by calipho-sib.
the class MasterIsoformMappingServiceIntegrationTest method shouldReturnIsoformsInProperOrder.
@Test
public void shouldReturnIsoformsInProperOrder() {
List<IsoformSpecificity> specs = this.mimService.findMasterIsoformMappingByEntryName("NX_Q8WZ42");
int i = 0;
for (IsoformSpecificity spec : specs) {
i++;
// TITIN has Iso 1, Iso 2, ... Iso 13
assertTrue(spec.getIsoformMainName().equals("Iso " + i));
}
assertTrue(true);
}
use of org.nextprot.api.core.domain.IsoformSpecificity in project nextprot-api by calipho-sib.
the class MasterIsoformMappingServiceIntegrationTest method shouldReturn2IsoformsWith2MappingPositionsEach.
@Test
public void shouldReturn2IsoformsWith2MappingPositionsEach() {
List<IsoformSpecificity> specs = this.mimService.findMasterIsoformMappingByEntryName("NX_P26439");
assertTrue(specs.size() == 2);
IsoformSpecificity spec;
spec = specs.get(0);
assertTrue(spec.getIsoformAc().equals("NX_P26439-1"));
assertTrue(spec.getIsoformMainName().equals("Iso 1"));
assertTrue(spec.getPositions().size() == 2);
spec = specs.get(1);
assertTrue(spec.getIsoformAc().equals("NX_P26439-2"));
assertTrue(spec.getIsoformMainName().equals("Iso 2"));
assertTrue(spec.getPositions().size() == 2);
}
use of org.nextprot.api.core.domain.IsoformSpecificity in project nextprot-api by calipho-sib.
the class MasterIsoformMappingDaoIntegrationTest method shouldReturn_4_Mappings.
@Test
public void shouldReturn_4_Mappings() {
List<IsoformSpecificity> specs = mimdao.findIsoformMappingByMaster("NX_P26439");
// for each of the 2 isoform we have 2 mapping positions: 2 x 2 = 4
assertTrue(specs.size() == 4);
for (IsoformSpecificity spec : specs) {
// is set later by service
assertTrue(spec.getIsoformMainName() == null);
assertTrue(spec.getIsoformAc() != null);
// we expect one position item by row and thus by IsoformSpecificity
assertTrue(spec.getPositions().size() == 1);
System.out.println(spec.toString());
}
}
use of org.nextprot.api.core.domain.IsoformSpecificity in project nextprot-api by calipho-sib.
the class MasterIsoformMappingServiceImpl method findMasterIsoformMappingByEntryName.
@Override
@Cacheable("master-isoform-mapping")
public List<IsoformSpecificity> findMasterIsoformMappingByEntryName(String entryName) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// build a map between isoform unique name and isoform main name
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
List<Isoform> isoforms = isoformService.findIsoformsByEntryName(entryName);
Map<String, String> unique2mainName = new HashMap<String, String>();
for (Isoform iso : isoforms) {
String mainName = iso.getMainEntityName().getValue();
unique2mainName.put(iso.getUniqueName(), mainName);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// group partial mappings obtained from DAO by isoform and set isoform name
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Map<String, IsoformSpecificity> map = new HashMap<String, IsoformSpecificity>();
List<IsoformSpecificity> specs = masterIsoformMappingDao.findIsoformMappingByMaster(entryName);
for (IsoformSpecificity tmpSpec : specs) {
String ac = tmpSpec.getIsoformAc();
if (!map.containsKey(ac))
map.put(ac, new IsoformSpecificity(null, ac));
IsoformSpecificity spec = map.get(ac);
// replace unique name with main name
spec.setIsoformMainName(unique2mainName.get(ac));
spec.addPosition(tmpSpec.getPositions().get(0));
}
List<IsoformSpecificity> list = new ArrayList<IsoformSpecificity>(map.values());
Collections.sort(list);
// returns a immutable list when the result is cacheable (this prevents modifying the cache, since the cache returns a reference) copy on read and copy on write is too much time consuming
return new ImmutableList.Builder<IsoformSpecificity>().addAll(list).build();
}
Aggregations