Skip to content

Commit

Permalink
Refactor CoExpressionService to work with Iterator of MolecularAltera…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
n1zea144 committed Jul 2, 2019
1 parent 24a1e8b commit a645fbe
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public interface MolecularDataRepository {
List<GeneMolecularAlteration> getGeneMolecularAlterations(String molecularProfileId, List<Integer> entrezGeneIds,
String projection);

Iterable<GeneMolecularAlteration> getGeneMolecularAlterationsIterable(String molecularProfileId, List<Integer> entrezGeneIds,
String projection);

List<GeneMolecularAlteration> getGeneMolecularAlterationsInMultipleMolecularProfiles(List<String> molecularProfileIds,
List<Integer> entrezGeneIds,
String projection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import org.cbioportal.model.GenesetMolecularAlteration;

import java.util.List;
import org.apache.ibatis.cursor.Cursor;

public interface MolecularDataMapper {

List<String> getCommaSeparatedSampleIdsOfMolecularProfiles(List<String> molecularProfileIds);

List<GeneMolecularAlteration> getGeneMolecularAlterations(String molecularProfileId, List<Integer> entrezGeneIds,
String projection);
Cursor<GeneMolecularAlteration> getGeneMolecularAlterations(String molecularProfileId, List<Integer> entrezGeneIds,
String projection);

List<GeneMolecularAlteration> getGeneMolecularAlterationsInMultipleMolecularProfiles(List<String> molecularProfileIds,
List<Integer> entrezGeneIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import org.cbioportal.model.GenesetMolecularAlteration;
import org.cbioportal.persistence.MolecularDataRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.*;
import org.springframework.stereotype.Repository;
import java.util.Arrays;
import java.util.List;
import java.util.*;

@Repository
public class MolecularDataMyBatisRepository implements MolecularDataRepository {
Expand All @@ -27,9 +27,27 @@ public List<String> getCommaSeparatedSampleIdsOfMolecularProfiles(List<String> m
}

@Override
// cursor processing requires a transaction
@Transactional(readOnly=true, propagation=Propagation.NESTED)
public List<GeneMolecularAlteration> getGeneMolecularAlterations(String molecularProfileId,
List<Integer> entrezGeneIds, String projection) {

List<GeneMolecularAlteration> toReturn = new ArrayList();
Iterable<GeneMolecularAlteration> gmasItr =
molecularDataMapper.getGeneMolecularAlterations(molecularProfileId, entrezGeneIds, projection);
for (GeneMolecularAlteration gma : gmasItr) {
toReturn.add(gma);
}
return toReturn;
}

@Override
// In order to return a cursor/iterator to the service layer, we need a transaction setup in the service
// layer. Currently, the bottom stackframe is CoExpressionService:getCoExpressions. It is there where
// you will find the transaction created.
public Iterable<GeneMolecularAlteration> getGeneMolecularAlterationsIterable(String molecularProfileId,
List<Integer> entrezGeneIds, String projection) {

return molecularDataMapper.getGeneMolecularAlterations(molecularProfileId, entrezGeneIds, projection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

Expand Down Expand Up @@ -43,6 +44,7 @@ public void getCommaSeparatedSampleIdsOfMolecularProfiles() throws Exception {
}

@Test
@Transactional(readOnly=true)
public void getGeneMolecularAlterations() throws Exception {

List<Integer> entrezGeneIds = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ List<GeneMolecularData> fetchMolecularData(String molecularProfileId, List<Strin
BaseMeta fetchMetaMolecularData(String molecularProfileId, List<String> sampleIds, List<Integer> entrezGeneIds)
throws MolecularProfileNotFoundException;

List<GeneMolecularAlteration> getMolecularAlterations(String molecularProfileId, List<Integer> entrezGeneIds,
String projection) throws MolecularProfileNotFoundException;
Iterable<GeneMolecularAlteration> getMolecularAlterations(String molecularProfileId, List<Integer> entrezGeneIds,
String projection) throws MolecularProfileNotFoundException;

Integer getNumberOfSamplesInMolecularProfile(String molecularProfileId);

Expand Down
Loading

0 comments on commit a645fbe

Please sign in to comment.