{"id":32619171,"url":"https://github.com/fnl/tred","last_synced_at":"2026-07-02T06:32:29.605Z","repository":{"id":139223161,"uuid":"2031345","full_name":"fnl/tred","owner":"fnl","description":"Scripts to extract, load, and write TG-TF-PMID relations via a Postgres DB.","archived":false,"fork":false,"pushed_at":"2014-02-03T14:17:12.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-11T13:18:37.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnl.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-07-11T16:38:32.000Z","updated_at":"2023-03-11T19:17:07.737Z","dependencies_parsed_at":"2023-03-14T05:15:45.764Z","dependency_job_id":null,"html_url":"https://github.com/fnl/tred","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/fnl/tred","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnl%2Ftred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnl%2Ftred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnl%2Ftred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnl%2Ftred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnl","download_url":"https://codeload.github.com/fnl/tred/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnl%2Ftred/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35036551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-30T18:00:29.299Z","updated_at":"2026-07-02T06:32:29.598Z","avatar_url":"https://github.com/fnl.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"#######################################\nLoad [parts of] a TRED DB into Postgres\n#######################################\n\nTwo scripts to load parts of the raw TRED DB release files into a Posgres DB.\n\nTested and working on OSX 10.6.7 and using Postgres 9.0.4 (64bit build).\n\nCurrent release version of these scripts: ``1.0``\n\nCopyright and license\n---------------------\n\nLicense: MIT (see below)\n\nCopyright (C) 2011 by Florian Leitner. All rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\nComponents\n----------\n\nA bash script to extract the data (``extract.sh``) and a SQL script to load the data, creating the tables, and doing some interesting queries (``tred.sql``).\n\nLimitations\n-----------\n\nThe current extraction focuses on extracting only those TRED interactions from the raw DB files that have (a) a PMID referencing the interaction, (b) a known database identifier for the transcription factor TF, and (c) a known database identifier for the target gene TG. Any relations that do not meet this criteria (about 10% of all stored TRED TF-TG relations) are dropped by the extraction step.\n\nEnvironment setup\n-----------------\n\nThe idea is to have a directory with the scripts, that has a subdirectory with the raw DB files received from TRED. The only bad idea is to name the subdirectory ``tmp``, which will be created by the extraction script. Otherwise, any (meaningful...) subdirectory name is suitable; the date was chosen to keep track of multiple downloads of the TRED DB, because the raw data we received from TRED itself did not seem to be identified with a version number::\n\n  mkdir tred\n  cd tred\n  mkdir \u003ctred db release date, e.g. 14_03_2011\u003e\n  cp /path/to/tred/data/*.txt 14_03_2011/\n  cp /path/to/tred.sql .\n  cp /path/to/extract.sh .\n\nPreparations\n------------\n\nIn the SQL script (``tred.sql``), set the correct path to this main tred directory just created::\n\n  vi tred.sql\n  :4\n  4w\n  c:r ! pwd\n  \u003cESC\u003e\n  J\n  x\n  x\n  $\n  a\n  '\n  \u003cESC\u003e\n  :wq\n\nThe result should be that line 4 in the file looks something like this::\n\n  \\set treddir '\\'/home/username/work/data/tred'\n\nStep-by-step instructions\n-------------------------\n\n**1. Create a DB in Postgres**\n\n\nYou can use any database name you desire; this is not of consequence in the further processing::\n\n  psql -c 'CREATE DATABASE tred'\n\n**2. Extract the data**\n\nThe next step will take a while, depending on the power of your machine. ``grep`` commands have been optimized, but it still takes a minute or two to run. The resulting raw file to dump into Postgres will be created in a directory 'tmp' relative to the CWD. The final line you should see is \"DONE\". You can re-run the script any time without having to create or clean the tmp directory extract.sh works with; it cleans the directory itself. The ouptut also shows you how many promoter entities and factor-to-promoter relations are being dropped due to the above mentioned limitations::\n\n  . extract.sh \u003craw files directory, eg., 14_03_2011 as described above\u003e\n\n**3. Dump the data, show statistics, write output file**\n\nRun the SQL script::\n\n  psql -f tred.sql tred\n\nYou will get some output about creating implicit indices, but otherwise the script should exit cleanly (status 0). The last argument (\"tred\") should be the DB you chose earlier. The last command of the script will copy a new table to your '/tmp' (notice: global /tmp, not the tmp dir described before!) directory, in a file 'FactorGeneEvidence.txt', that contains what I had \"hoped\" to have found in TRED initially: All unique TG-TF-PMID triples, with the following columns:\n\n#. PMID\n#. TF source DB\n#. TF source DB accession\n#. TG source DB\n#. TG source DB accession\n\nThe last command also gives you some interesting statistics of the loaded data right away. For my run on the TRED data, the statistics were:\n\n* Curated Factor-Gene-PubMed Triples: ``6765``\n* Curated Publications: ``3494``\n\nNote that the Factor-Gene-PubMed Triples are for **unique** factor-to-gene relations, while the file produced in /tmp holds far more than those, because for each such unique triplet multiple *accessions* might exist on each side (ie., for the TF and TG). Also note that both numbers and the extracted file are not over all triples/publications in the TRED DB, but only for those that meet certain selection criteria: the TF-promoter relation curation quality must be 'known' (``fp_quality = 1``) and the promoter quality itself must be 'known' or 'known, curated' (``p_quality \u003c 3``).\n\nThat's it, folks - **good luck**!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnl%2Ftred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnl%2Ftred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnl%2Ftred/lists"}