Skip to content

Commit

Permalink
Update submission functions (#80)
Browse files Browse the repository at this point in the history
* update submissions

* update tests
  • Loading branch information
rvhonorato authored Aug 31, 2023
1 parent 16f0b65 commit 25c807c
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 47 deletions.
5 changes: 3 additions & 2 deletions src/cport/modules/cons_ppisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def submit(self):
input_form.set(name="submitter", value=str(self.chain_id))
input_form.set(name="emailAddr", value="[email protected]")
input_form.set(name="pChain", value=self.chain_id)
input_form.set(name="userfile", value=self.pdb_file)
browser.submit_selected()
with open(self.pdb_file, "rb") as file_obj:
input_form.set(name="userfile", value=file_obj)
browser.submit_selected()

# https://regex101.com/r/FBgZFE/1
processing_url = re.findall(r"<a href=\"(.*)\">this link<", str(browser.page))[
Expand Down
2 changes: 1 addition & 1 deletion src/cport/modules/csm_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def submit(self):
req = requests.post(CSM_POTENTIAL_URL, files=data)

response = req.json()
if response["job_id"]:
if "job_id" in response:
# successful submission
job_id = response["job_id"]
else:
Expand Down
7 changes: 4 additions & 3 deletions src/cport/modules/ispred4.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ def submit(self):
browser.open(ISPRED4_URL)

input_form = browser.select_form(nr=0)
input_form.set(name="structure", value=self.pdb_file)
input_form.set(name="ispred_chain", value=self.chain_id)
input_form.set(
name="ispred_rsath", value="0.20"
) # this is the default value, could be changed for analysis later
browser.submit_selected()
with open(self.pdb_file, "rb") as file_obj:
input_form.set(name="structure", value=file_obj)
# input_form.set(name="structure", value=self.pdb_file)
browser.submit_selected()

# https://regex101.com/r/KFLLil/1
job_id = re.findall(r"Jobid:.*?;\">(.*?)</div>", str(browser.page))[0]
Expand Down Expand Up @@ -143,7 +145,6 @@ def download_result(download_link):
"""
temp_file = tempfile.NamedTemporaryFile(delete=False)
# trunk-ignore(bandit/B310)
request.urlretrieve(download_link, temp_file.name)
return temp_file.name

Expand Down
5 changes: 3 additions & 2 deletions src/cport/modules/meta_ppisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def submit(self):
input_form.set(name="submitter", value=str(self.chain_id))
input_form.set(name="emailAddr", value="[email protected]")
input_form.set(name="pChain", value=self.chain_id)
input_form.set(name="userfile", value=self.pdb_file)
browser.submit_selected()
with open(self.pdb_file, "rb") as file_obj:
input_form.set(name="userfile", value=file_obj)
browser.submit_selected()

# https://regex101.com/r/FBgZFE/1
processing_url = re.findall(r"<a href=\"(.*)\">this link<", str(browser.page))[
Expand Down
5 changes: 3 additions & 2 deletions src/cport/modules/predus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def submit(self):
browser.open(PREDUS2_URL, verify=False)

input_form = browser.select_form(nr=0)
input_form.set(name="userfile", value=filename)
browser.submit_selected()
with open(filename, "rb") as file_obj:
input_form.set(name="userfile", value=file_obj)
browser.submit_selected()

# finds the submission url from the many links present on the page
# https://regex101.com/r/Do6b51/1
Expand Down
5 changes: 3 additions & 2 deletions src/cport/modules/scannet.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def submit(self):
browser.open(SCANNET_URL, verify=False)

input_form = browser.select_form(nr=0)
input_form.set(name="PDBfile", value=self.pdb_file)
input_form.set(name="email", value="[email protected]")
input_form.set(name="chain", value=self.chain_id)
browser.submit_selected()
with open(self.pdb_file, "rb") as file_obj:
input_form.set(name="PDBfile", value=file_obj)
browser.submit_selected()

browser.follow_link(browser.links()[7])
processing_url = browser.get_url()
Expand Down
6 changes: 3 additions & 3 deletions src/cport/modules/sppider.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def submit(self):
browser.open(SPPIDER_URL)

sppider_form = browser.select_form()
sppider_form.set(name="PDBFileName", value=self.pdb_file)

browser.submit_selected()
with open(self.pdb_file, "rb") as file_obj:
sppider_form.set(name="PDBFileName", value=file_obj)
browser.submit_selected()

sppider_links = browser.links()
browser.follow_link(sppider_links[0])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cons_ppisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def cons_ppisp():
yield ConsPPISP("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the cons-PPISP server is up")
def test_submit():
pass
def test_submit(cons_ppisp):
summary_url = cons_ppisp.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(cons_ppisp):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_csm_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def csm_potential():
yield CsmPotential("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the CSM-Potential server is up")
def test_submit():
pass
@pytest.mark.skip("CSM-Potential is not working")
def test_submit(csm_potential):
summary_url = csm_potential.submit()
assert isinstance(summary_url, str)


def test_parse_prediction(csm_potential, precalc_result):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ispred4.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def ispred4():
yield Ispred4("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the ISPRED4 server is up")
def test_submit():
pass
def test_submit(ispred4):
summary_url = ispred4.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(ispred4):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_meta_ppisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def meta_ppisp():
yield MetaPPISP("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the meta-PPISP server is up")
def test_submit():
pass
def test_submit(meta_ppisp):
summary_url = meta_ppisp.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(meta_ppisp):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_predictprotein.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def predictprotein():
yield Predictprotein("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the Predict Protein server is up")
def test_submit():
pass
def test_submit(predictprotein):
summary_url = predictprotein.submit()
assert isinstance(summary_url, str)


def test_parse_prediction(predictprotein, precalc_result):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_predus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def predus2():
yield Predus2("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the PredUs2 server is up")
def test_submit():
pass
def test_submit(predus2):
summary_url = predus2.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(predus2):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_psiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def psiver():
yield Psiver("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the PSIVER server is up")
def test_submit():
pass
def test_submit(psiver):
summary_url = psiver.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(psiver):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_scannet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def scannet():
yield ScanNet("tests/test_data/1PPE.pdb", "A")


@pytest.mark.skip("Cannot guarantee that the cons-PPISP server is up")
def test_submit():
pass
@pytest.mark.skip("server is down")
def test_submit(scannet):
summary_url = scannet.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(scannet):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_scriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def scriber():
yield Scriber("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the Scriber server is up")
def test_submit():
pass
def test_submit(scriber):
summary_url = scriber.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(scriber):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_sppider.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def sppider():
yield Sppider("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot guarantee that the SPPIDER server is up")
def test_submit():
pass
def test_submit(sppider):
summary_url = sppider.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction_link(sppider):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_whiscy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def whiscy():
yield Whiscy("tests/test_data/1PPE.pdb", "E")


@pytest.mark.skip("Cannot test the submission")
@pytest.mark.skip("FIXME: Split into smaller tests")
def test_submit(whiscy):
pass
summary_url = whiscy.submit()
assert isinstance(summary_url, str)


def test_retrieve_prediction(whiscy):
Expand Down

0 comments on commit 25c807c

Please sign in to comment.