Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CoExpressionService to work with iterator over MolecularAlteration objects. #6302

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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