Skip to content

Commit 53d8aee

Browse files
committed
Merge branch 'dev'
2 parents b27bc58 + f71e440 commit 53d8aee

File tree

12 files changed

+103
-105
lines changed

12 files changed

+103
-105
lines changed

README.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ A significant amount of development is typically required to join the MME; this
2323

2424
## Build:
2525

26-
You can build <i>matchbox</i> via two methods.
27-
28-
1. Directly through maven. [Detailed maven build instructions](deploy/maven/README.md)
29-
30-
OR
31-
32-
2. Using [Docker](https://www.docker.com/). [Detailed Docker build instructions](deploy/docker/README.md)
26+
You can build <i>matchbox</i> using [Docker](https://www.docker.com/). Detailed Docker build instructions can be found [here](deploy/docker/README.md)
3327

3428

3529
## General overview:

deploy/maven/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Build directly via Maven:
22

3+
### Please note we do not support installation through Maven anymore. Please consider these pages deprecated
4+
5+
36
### You will need:
47

58
* Java 1.8

regression-tests/build_local_mme_network.py

+42-45
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,50 @@ def start_local_master_node():
4343

4444
def start_instance(local_ip_address,instance,directories):
4545
'''
46-
Starts a mongodb instance and its matchbox instance
46+
Starts a matchbox instance
4747
'''
48-
print 'working on:',directories['prefix'],directories
48+
print ('working on: %s, %s' % (directories['prefix'],directories))
4949
err=None
5050
os.chdir(directories['matchbox_dir'])
5151
if not os.path.exists('matchbox'):
5252
p = subprocess.Popen(['git','clone','-b','dev','https://github.com/macarthur-lab/matchbox'],stdout=subprocess.PIPE)
5353
(output, err) = p.communicate()
5454
else:
55-
print '----WARNING:','that repo already exists, not cloning a new copy:',directories['matchbox_dir']
55+
print ('----WARNING: that repo already exists, not cloning a new copy: %s' % directories['matchbox_dir'])
5656
if err is None:
57-
mongo_port = start_dockerized_mongodb(instance,directories)
58-
start_dockerized_matchbox(local_ip_address,mongo_port,instance,directories)
57+
start_dockerized_matchbox(local_ip_address,instance,directories)
5958
return
6059

6160

62-
def start_dockerized_matchbox(local_ip_address,mongo_port,instance,directories):
61+
def start_dockerized_matchbox(local_ip_address,instance,directories):
6362
'''
6463
Starts a single HTTPS matchbox instance
6564
Args:
66-
mongo_port: the port of the MongoDB instance slated for this matchbox instance
6765
instance: int representing this instance
68-
dictories: information on path and prefixes for this instance
66+
directories: information on path and prefixes for this instance
6967
'''
68+
mongo_port=27017
7069
instance_port = 8443 + instance
70+
71+
#----------------update entrypoint file
72+
existing_entrypointfile = 'matchbox/deploy/docker/with_data_in_container/entrypoint.sh'
73+
updated_entrypointfile = 'matchbox/deploy/docker/with_data_in_container/entrypoint_updated.sh'
74+
with open(existing_entrypointfile,'r') as ei:
75+
entrypointfile_lines = ei.readlines()
76+
ei.close()
77+
with open (updated_entrypointfile,'w') as eo:
78+
l=0
79+
while l<len(entrypointfile_lines):
80+
line=entrypointfile_lines[l]
81+
if l==2:
82+
eo.write('mongod --dbpath=. --fork --logpath mongo_log.txt')
83+
eo.write('\n')
84+
eo.write(line)
85+
l+=1
86+
eo.close()
87+
os.chmod(updated_entrypointfile, 777)
88+
89+
#----------------update Docker file
7190
existing_dockerfile = 'matchbox/deploy/docker/with_data_in_container/Dockerfile'
7291
updated_dockerfile = 'matchbox/deploy/docker/with_data_in_container/Dockerfile.net'
7392
with open(existing_dockerfile,'r') as di:
@@ -78,11 +97,11 @@ def start_dockerized_matchbox(local_ip_address,mongo_port,instance,directories):
7897
while l<len(dockerfile_lines):
7998
line=dockerfile_lines[l]
8099
if "env MONGODB_HOSTNAME" in line:
81-
do.write(line.strip()+local_ip_address)
100+
do.write(line.strip()+'localhost')
82101
elif "MONGODB_DATABASE" in line:
83102
do.write(line.strip()+"mme_primary")
84103
elif "env MONGODB_PORT" in line:
85-
do.write(line.strip().split("=")[0]+'='+mongo_port)
104+
do.write(line.strip().split("=")[0]+'='+str(mongo_port))
86105
elif "env USE_HTTPS" in line:
87106
do.write(line.strip().split("=")[0]+'='+'true\n')
88107
l+=1
@@ -93,6 +112,10 @@ def start_dockerized_matchbox(local_ip_address,mongo_port,instance,directories):
93112
do.write(dockerfile_lines[l].replace("#",""))
94113
l+=1
95114
do.write(dockerfile_lines[l].replace("#",""))
115+
elif "entrypoint.sh" in line:
116+
do.write('RUN apt-get -y install mongodb')
117+
do.write('\n')
118+
do.write(line.replace("entrypoint.sh", "entrypoint_updated.sh"))
96119
else:
97120
do.write(line.strip())
98121
do.write('\n')
@@ -101,41 +124,20 @@ def start_dockerized_matchbox(local_ip_address,mongo_port,instance,directories):
101124
image_name = directories['prefix'] + '_img'
102125
os.chdir('matchbox/deploy/docker/with_data_in_container/')
103126
p = subprocess.Popen(['docker','build','-t',image_name,'-f',updated_dockerfile.split('/')[-1],'.'],stdout=subprocess.PIPE)
104-
(output, err) = p.communicate()
105-
print output,err
127+
(output, build_err) = p.communicate()
128+
print ("build output: %s, build error(if any):%s " % (output,build_err))
129+
if not build_err:
130+
print (' '.join(['docker','run','-dti','-p', str(instance_port)+":"+str(instance_port),image_name]))
131+
p = subprocess.Popen(['docker','run','-dti','-p', str(instance_port)+":"+str(instance_port),image_name],stdout=subprocess.PIPE)
132+
(output, run_err) = p.communicate()
133+
print ("image run output: %s, run error(if any): %s " % (output,run_err))
106134
return
107135

108136

109137

110138

111139

112140

113-
114-
def start_dockerized_mongodb(instance,directories):
115-
'''
116-
Starts a mongodb instance
117-
Args:
118-
instance: an int representing the instance number
119-
directories: a dictionary of various related dirs to this instance
120-
Returns:
121-
The mongo port this instance runs on
122-
'''
123-
if instance > 9:
124-
print "----WARNING:","skipping instance (too high!):",instance
125-
return
126-
mongo_port='2701'+str(instance)
127-
mongo_prefix=directories['prefix']+'_mongo'
128-
cmd = ['docker','run','--name',mongo_prefix,'-d','-p',mongo_port+':27017', '-v',directories['mongo_data_dir'].split('/')[-1]+':/data/db','mongo']
129-
p = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
130-
(output, err) = p.communicate()
131-
if not err:
132-
return mongo_port
133-
if "Conflict" in err and mongo_prefix in err:
134-
print "----WARNING:","skipping creating new mongo container, looks like one is still up:",mongo_prefix
135-
return mongo_port
136-
return None
137-
138-
139141
def buid_dir_struct(root_path,timestamp,num_instances):
140142
'''
141143
Build a directory structure for network
@@ -146,16 +148,11 @@ def buid_dir_struct(root_path,timestamp,num_instances):
146148
for i in xrange(0,num_instances):
147149
prefix = 'matchbox_' + str(i)
148150
matchbox_dir= timestamp + '/' + prefix
149-
mongo_data_dir= matchbox_dir + '/mongo_data_dir_'+prefix
150-
directories[i]={'matchbox_dir':matchbox_dir, 'mongo_data_dir':mongo_data_dir,"prefix":prefix,"root_path":root_path}
151+
directories[i]={'matchbox_dir':matchbox_dir,"prefix":prefix,"root_path":root_path}
151152
if not os.path.exists(matchbox_dir):
152153
os.makedirs(matchbox_dir)
153154
else:
154-
print "----WARNING:",matchbox_dir,"exists, skipping directory creation"
155-
if not os.path.exists(mongo_data_dir):
156-
os.makedirs(mongo_data_dir)
157-
else:
158-
print "----WARNING:",mongo_data_dir,"exists, skipping directory creation"
155+
print ("----WARNING: %s exists, skipping directory creation" % matchbox_dir)
159156
return directories
160157

161158

src/main/java/org/broadinstitute/macarthurlab/matchbox/controllers/MatchController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ public ResponseEntity<?> match(@RequestBody String requestString, HttpServletReq
7070
msg.append(queryPatient.getContact().toString());
7171
msg.append(", orignating from matchmaker node:");
7272
msg.append(originMatchmakerNodeName);
73-
logger.warn(msg.toString());
73+
logger.warn("{}",msg);
7474
} else {
75-
logger.warn("input data invalid: {}",inputData.toString());
75+
logger.warn("input data invalid: {}",inputData);
7676
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
7777
}
7878
} catch (Exception e) {

src/main/java/org/broadinstitute/macarthurlab/matchbox/controllers/PatientController.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,30 @@ public ResponseEntity<String> add(@RequestBody String requestString) {
6666
StringBuilder msg = new StringBuilder();
6767
msg.append("add to MME request has invalid JSON data:");
6868
msg.append(decodedRequestString);
69-
System.out.println(msg.toString());
70-
return new ResponseEntity<String>(msg.toString(),HttpStatus.BAD_REQUEST);
69+
this.getLogger().info(" {} ",msg);
70+
return new ResponseEntity<>(msg.toString(),HttpStatus.BAD_REQUEST);
7171
}
7272
//if the patient doesn't exist already, add them
7373
patient = this.getPatientUtility().parsePatientInformation(inputData);
7474
Patient recordInDb = this.patientMongoRepository.findOne(patient.getId());
7575
if (null == recordInDb) {
7676
this.patientMongoRepository.insert(patient);
77-
this.getLogger().info("inserting new patient for the first time: " + patient.toString());
77+
this.getLogger().info("inserting new patient for the first time: {}", patient);
7878
} else {
7979
//let's delete the existing record and add in the new one.
80-
//#TODO add an audit here for external users who don't use seqr to audit this
8180
this.patientMongoRepository.delete(recordInDb);
8281
this.patientMongoRepository.insert(patient);
83-
this.getLogger().info("deleting existing patient record and inserting new patient record: " + patient.toString());
82+
this.getLogger().info("deleting existing patient record and inserting new patient record: {} ",patient);
8483
jsonMessage = "{\"message\":\"That patient record (specifically that ID) had already been submitted in the past, it already exists in Broad system. We are deleting that record and updating it with this new submission\",\"status_code\":200}";
85-
return new ResponseEntity<String>(jsonMessage, HttpStatus.CONFLICT);
84+
return new ResponseEntity<>(jsonMessage, HttpStatus.CONFLICT);
8685
}
8786
} catch (Exception e) {
8887
this.getLogger().error(e.getMessage());
8988
jsonMessage = "{\"message\":\"unable to insert, an unknown error occurred.\",\"status_code\":442, \"error_message\":\""
9089
+ e.getMessage() + "\"}";
91-
return new ResponseEntity<String>(jsonMessage, HttpStatus.SERVICE_UNAVAILABLE);
90+
return new ResponseEntity<>(jsonMessage, HttpStatus.SERVICE_UNAVAILABLE);
9291
}
93-
return new ResponseEntity<String>(jsonMessage, HttpStatus.OK);
92+
return new ResponseEntity<>(jsonMessage, HttpStatus.OK);
9493
}
9594

9695

@@ -127,16 +126,16 @@ public ResponseEntity<String> delete(@RequestBody String requestString) {
127126
}
128127
if (numDeleted==0){
129128
jsonMessage = "{\"message\":\"no patients were deleted, are you sure that ID was valid?\",\"status_code\":400\"}";
130-
return new ResponseEntity<String>(jsonMessage, HttpStatus.BAD_REQUEST);
129+
return new ResponseEntity<>(jsonMessage, HttpStatus.BAD_REQUEST);
131130
}
132131
}
133132
catch(Exception e){
134133
jsonMessage = "{\"message\":\"unable to delete, an unknown error occurred.\",\"status_code\":442, \"error_message\":\""
135134
+ e.getMessage() + "\"}";
136135
this.getLogger().error(e.getMessage());
137-
return new ResponseEntity<String>(jsonMessage, HttpStatus.MULTI_STATUS);
136+
return new ResponseEntity<>(jsonMessage, HttpStatus.MULTI_STATUS);
138137
}
139-
return new ResponseEntity<String>(jsonMessage, HttpStatus.OK);
138+
return new ResponseEntity<>(jsonMessage, HttpStatus.OK);
140139
}
141140

142141

src/main/java/org/broadinstitute/macarthurlab/matchbox/entities/GenomicFeature.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public class GenomicFeature {
5656
* @param type type
5757
*/
5858
public GenomicFeature() {
59-
this.gene = new HashMap<String, String>();
59+
this.gene = new HashMap<>();
6060
this.variant = new Variant();
6161
this.zygosity = -1L;
62-
this.type = new HashMap<String,String>();
62+
this.type = new HashMap<>();
6363
}
6464

6565
/**
@@ -132,7 +132,7 @@ public String getEmptyFieldsRemovedJson(){
132132
asJson.append("}");
133133
}
134134

135-
if (!this.getVariant().isUnPopulated()){
135+
if (!this.getVariant().isUnPopulated() && this.getVariant().shareVariantLevelData()){
136136
asJson.append(",");
137137
asJson.append("\"variant\":");
138138
asJson.append(this.getVariant().getEmptyFieldsRemovedJson());
@@ -154,7 +154,7 @@ public String getEmptyFieldsRemovedJson(){
154154
break;
155155
}
156156
}
157-
if (hasType == true) {
157+
if (hasType) {
158158
asJson.append("\"type\":{");
159159
int i=0;
160160
for (String k2 : this.getType().keySet()) {

src/main/java/org/broadinstitute/macarthurlab/matchbox/entities/MatchmakerResult.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class MatchmakerResult {
2525
* Default constructor makes empty result object
2626
*/
2727
public MatchmakerResult() {
28-
this.score = new HashMap<String,Double>();
28+
this.score = new HashMap<>();
2929
this.patient = new Patient();
3030
}
3131

@@ -54,7 +54,6 @@ public Patient getPatient() {
5454
}
5555

5656

57-
5857
/**
5958
* Returns a JSON representation and keeps out empty fields
6059
* @return A JSON string

src/main/java/org/broadinstitute/macarthurlab/matchbox/entities/Variant.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Variant {
1414
private final Long end;
1515
private final String referenceBases;
1616
private final String alternateBases;
17+
private final boolean shareVariantLevelData;
1718

1819

1920

@@ -30,13 +31,15 @@ public Variant(String assembly,
3031
Long start,
3132
Long end,
3233
String referenceBases,
33-
String alternateBases) {
34+
String alternateBases,
35+
boolean shareVariantLevelData) {
3436
this.assembly = assembly;
3537
this.referenceName = referenceName;
3638
this.start = start;
3739
this.end = end;
3840
this.referenceBases = referenceBases;
3941
this.alternateBases = alternateBases;
42+
this.shareVariantLevelData = shareVariantLevelData;
4043
}
4144

4245
/**
@@ -49,6 +52,7 @@ public Variant(){
4952
this.end=0L;
5053
this.referenceBases="";
5154
this.alternateBases="";
55+
this.shareVariantLevelData=true;
5256
}
5357

5458
/**
@@ -112,7 +116,13 @@ public String getReferenceBases() {
112116
public String getAlternateBases() {
113117
return alternateBases;
114118
}
115-
119+
120+
/**
121+
* @return the shareVariantLevelData
122+
*/
123+
public boolean shareVariantLevelData() {
124+
return shareVariantLevelData;
125+
}
116126

117127
/* To string method
118128
* (non-Javadoc)
@@ -121,7 +131,7 @@ public String getAlternateBases() {
121131
@Override
122132
public String toString() {
123133
return "Variant [assembly=" + assembly + ", referenceName=" + referenceName + ", start=" + start + ", end="
124-
+ end + ", referenceBases=" + referenceBases + ", alternateBases=" + alternateBases + "]";
134+
+ end + ", referenceBases=" + referenceBases + ", alternateBases=" + alternateBases + ", shareVariantLevelData=" + shareVariantLevelData + "]";
125135
}
126136

127137

src/main/java/org/broadinstitute/macarthurlab/matchbox/search/MatchmakerSearchImpl.java

+2-14
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public List<String> searchInLocalDatabaseOnly(Patient queryPatient, String hostN
103103
}
104104
}
105105

106-
/**
106+
/**************************************************
107107
* persist for logging and metrics and tracking of data sent out. Persist the
108108
* incoming query ONLY if a match is made, otherwise don't keep any of the
109109
* information that is sent in, which is only fair.
@@ -124,20 +124,8 @@ public List<String> searchInLocalDatabaseOnly(Patient queryPatient, String hostN
124124
queryPatient.getContact().get("institution"),
125125
false);
126126
}
127+
//**************************************************
127128
operator.save(externalQueryMatch);
128-
129-
/*
130-
* Send an email alert to local data owners where there is a match returned
131-
*/
132-
if (scrubbedResults.size()>0){
133-
//System.out.println(scrubbedResults);
134-
//HtmlEmail email = new HtmlEmail();
135-
//email.setHostName("smtp.gmail.com");
136-
//email.setSmtpPort(465);
137-
//email.setSSLOnConnect(true);
138-
//email.setAuthentication("[email protected]", "your-password");
139-
}
140-
141129
return scrubbedResults;
142130
}
143131

0 commit comments

Comments
 (0)