20210317

メールアドレスの正規表現チェックとSRAリンク取得

テキストボックスに入力されたメールアドレスが正規表現にマッチしているか確認

var regex = /^[a-zA-Z0-9_.+-]+@([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$/;
//以下ボタンクリック時に実行する関数中
email = $("#email")[0].value;
if (!(regex.test(email))) {
  console.log("incorrect email address");
  return
}

サーバに送られたメールアドレスが正規表現にマッチしているかを確認

router.post('/upload', function (req, res, next) {
  var regex = /^[a-zA-Z0-9_.+-]+@([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$/;
  if (!(regex.test(req.body.email))) {
      console.log("incorrect email address");
      return
  }
  //res.render('uploaded');
  console.log(req.body);  
});

アウトプットファイルからID,そのサンプル情報のURL,提出元,研究テーマ,サンプル名を取得し、HTMLファイルに出力するスクリプトを作成

# coding: utf-8 import sys import subprocess argv = sys.argv

引数からファイルを取得

resultfname = argv[1] resultfnameheader = resultfname.replace(“.result”,“”) resultf = open(result_f_name)

url_template = “https://www.ncbi.nlm.nih.gov/sra/?term=

olheader = “<ol>” olfooter = “</ol>”

htmlcontent = “” htmlcontent = htmlcontent + olheader

rowslist = resultf.readlines() for row in rowslist: #各行からIDだけを取得 srrid = row.split()[0]

  srr_id = srr_id.replace(".fastq","")
  # print(srr_id)
  #各行からURLを作成
  url = url_template + srr_id
  # print(url)
  #各行から生成したURLでアクセスし、HTMLファイルを取得し、サンプル情報などを取得
  cmd = ["bash", "html_parse.sh", url]
  res = subprocess.check_output(cmd).decode().split("\n")
  submited_by = res[0]
  study = res[1]
  sample = res[3]
  #HTMLファイルの中身を作成
  html_content = html_content + "<li><a href=" + url + ">" + srr_id + "</a><ul><li>Submited by: " + submited_by + "</li><li>Study: " + study + "</li><li>Sample: " + sample + "</li></ul></li>"
  # print(submited_by)
  # print(study)
  # print(sample)

htmlcontent = htmlcontent + olfooter # print(htmlcontent)

アウトプットファイルとして保存

outputfname = resultfnameheader + “.html” outputf = open(outputfname, “w”) outputf.write(htmlcontent) output_f.close()

result_f.close()

  • 20210317.1615968296.txt.gz
  • 最終更新: 2021/03/17 08:04
  • by 133.11.144.10